author | haftmann |
Wed, 21 Jan 2009 16:47:31 +0100 | |
changeset 29580 | 117b88da143c |
parent 29509 | 1ff0f3f08a7b |
child 29609 | a010aab5bed0 |
permissions | -rw-r--r-- |
12396 | 1 |
(* Title: HOL/Finite_Set.thy |
2 |
Author: Tobias Nipkow, Lawrence C Paulson and Markus Wenzel |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
3 |
with contributions by Jeremy Avigad |
12396 | 4 |
*) |
5 |
||
6 |
header {* Finite sets *} |
|
7 |
||
15131 | 8 |
theory Finite_Set |
27981 | 9 |
imports Datatype Divides Transitive_Closure |
15131 | 10 |
begin |
12396 | 11 |
|
15392 | 12 |
subsection {* Definition and basic properties *} |
12396 | 13 |
|
23736 | 14 |
inductive finite :: "'a set => bool" |
22262 | 15 |
where |
16 |
emptyI [simp, intro!]: "finite {}" |
|
17 |
| insertI [simp, intro!]: "finite A ==> finite (insert a A)" |
|
12396 | 18 |
|
13737 | 19 |
lemma ex_new_if_finite: -- "does not depend on def of finite at all" |
14661 | 20 |
assumes "\<not> finite (UNIV :: 'a set)" and "finite A" |
21 |
shows "\<exists>a::'a. a \<notin> A" |
|
22 |
proof - |
|
28823 | 23 |
from assms have "A \<noteq> UNIV" by blast |
14661 | 24 |
thus ?thesis by blast |
25 |
qed |
|
12396 | 26 |
|
22262 | 27 |
lemma finite_induct [case_names empty insert, induct set: finite]: |
12396 | 28 |
"finite F ==> |
15327
0230a10582d3
changed the order of !!-quantifiers in finite set induction.
nipkow
parents:
15318
diff
changeset
|
29 |
P {} ==> (!!x F. finite F ==> x \<notin> F ==> P F ==> P (insert x F)) ==> P F" |
12396 | 30 |
-- {* Discharging @{text "x \<notin> F"} entails extra work. *} |
31 |
proof - |
|
13421 | 32 |
assume "P {}" and |
15327
0230a10582d3
changed the order of !!-quantifiers in finite set induction.
nipkow
parents:
15318
diff
changeset
|
33 |
insert: "!!x F. finite F ==> x \<notin> F ==> P F ==> P (insert x F)" |
12396 | 34 |
assume "finite F" |
35 |
thus "P F" |
|
36 |
proof induct |
|
23389 | 37 |
show "P {}" by fact |
15327
0230a10582d3
changed the order of !!-quantifiers in finite set induction.
nipkow
parents:
15318
diff
changeset
|
38 |
fix x F assume F: "finite F" and P: "P F" |
12396 | 39 |
show "P (insert x F)" |
40 |
proof cases |
|
41 |
assume "x \<in> F" |
|
42 |
hence "insert x F = F" by (rule insert_absorb) |
|
43 |
with P show ?thesis by (simp only:) |
|
44 |
next |
|
45 |
assume "x \<notin> F" |
|
46 |
from F this P show ?thesis by (rule insert) |
|
47 |
qed |
|
48 |
qed |
|
49 |
qed |
|
50 |
||
15484 | 51 |
lemma finite_ne_induct[case_names singleton insert, consumes 2]: |
52 |
assumes fin: "finite F" shows "F \<noteq> {} \<Longrightarrow> |
|
53 |
\<lbrakk> \<And>x. P{x}; |
|
54 |
\<And>x F. \<lbrakk> finite F; F \<noteq> {}; x \<notin> F; P F \<rbrakk> \<Longrightarrow> P (insert x F) \<rbrakk> |
|
55 |
\<Longrightarrow> P F" |
|
56 |
using fin |
|
57 |
proof induct |
|
58 |
case empty thus ?case by simp |
|
59 |
next |
|
60 |
case (insert x F) |
|
61 |
show ?case |
|
62 |
proof cases |
|
23389 | 63 |
assume "F = {}" |
64 |
thus ?thesis using `P {x}` by simp |
|
15484 | 65 |
next |
23389 | 66 |
assume "F \<noteq> {}" |
67 |
thus ?thesis using insert by blast |
|
15484 | 68 |
qed |
69 |
qed |
|
70 |
||
12396 | 71 |
lemma finite_subset_induct [consumes 2, case_names empty insert]: |
23389 | 72 |
assumes "finite F" and "F \<subseteq> A" |
73 |
and empty: "P {}" |
|
74 |
and insert: "!!a F. finite F ==> a \<in> A ==> a \<notin> F ==> P F ==> P (insert a F)" |
|
75 |
shows "P F" |
|
12396 | 76 |
proof - |
23389 | 77 |
from `finite F` and `F \<subseteq> A` |
78 |
show ?thesis |
|
12396 | 79 |
proof induct |
23389 | 80 |
show "P {}" by fact |
81 |
next |
|
82 |
fix x F |
|
83 |
assume "finite F" and "x \<notin> F" and |
|
84 |
P: "F \<subseteq> A ==> P F" and i: "insert x F \<subseteq> A" |
|
12396 | 85 |
show "P (insert x F)" |
86 |
proof (rule insert) |
|
87 |
from i show "x \<in> A" by blast |
|
88 |
from i have "F \<subseteq> A" by blast |
|
89 |
with P show "P F" . |
|
23389 | 90 |
show "finite F" by fact |
91 |
show "x \<notin> F" by fact |
|
12396 | 92 |
qed |
93 |
qed |
|
94 |
qed |
|
95 |
||
23878 | 96 |
|
15392 | 97 |
text{* Finite sets are the images of initial segments of natural numbers: *} |
98 |
||
15510 | 99 |
lemma finite_imp_nat_seg_image_inj_on: |
100 |
assumes fin: "finite A" |
|
101 |
shows "\<exists> (n::nat) f. A = f ` {i. i<n} & inj_on f {i. i<n}" |
|
15392 | 102 |
using fin |
103 |
proof induct |
|
104 |
case empty |
|
15510 | 105 |
show ?case |
106 |
proof show "\<exists>f. {} = f ` {i::nat. i < 0} & inj_on f {i. i<0}" by simp |
|
107 |
qed |
|
15392 | 108 |
next |
109 |
case (insert a A) |
|
23389 | 110 |
have notinA: "a \<notin> A" by fact |
15510 | 111 |
from insert.hyps obtain n f |
112 |
where "A = f ` {i::nat. i < n}" "inj_on f {i. i < n}" by blast |
|
113 |
hence "insert a A = f(n:=a) ` {i. i < Suc n}" |
|
114 |
"inj_on (f(n:=a)) {i. i < Suc n}" using notinA |
|
115 |
by (auto simp add: image_def Ball_def inj_on_def less_Suc_eq) |
|
15392 | 116 |
thus ?case by blast |
117 |
qed |
|
118 |
||
119 |
lemma nat_seg_image_imp_finite: |
|
120 |
"!!f A. A = f ` {i::nat. i<n} \<Longrightarrow> finite A" |
|
121 |
proof (induct n) |
|
122 |
case 0 thus ?case by simp |
|
123 |
next |
|
124 |
case (Suc n) |
|
125 |
let ?B = "f ` {i. i < n}" |
|
126 |
have finB: "finite ?B" by(rule Suc.hyps[OF refl]) |
|
127 |
show ?case |
|
128 |
proof cases |
|
129 |
assume "\<exists>k<n. f n = f k" |
|
130 |
hence "A = ?B" using Suc.prems by(auto simp:less_Suc_eq) |
|
131 |
thus ?thesis using finB by simp |
|
132 |
next |
|
133 |
assume "\<not>(\<exists> k<n. f n = f k)" |
|
134 |
hence "A = insert (f n) ?B" using Suc.prems by(auto simp:less_Suc_eq) |
|
135 |
thus ?thesis using finB by simp |
|
136 |
qed |
|
137 |
qed |
|
138 |
||
139 |
lemma finite_conv_nat_seg_image: |
|
140 |
"finite A = (\<exists> (n::nat) f. A = f ` {i::nat. i<n})" |
|
15510 | 141 |
by(blast intro: nat_seg_image_imp_finite dest: finite_imp_nat_seg_image_inj_on) |
15392 | 142 |
|
26441 | 143 |
|
15392 | 144 |
subsubsection{* Finiteness and set theoretic constructions *} |
145 |
||
12396 | 146 |
lemma finite_UnI: "finite F ==> finite G ==> finite (F Un G)" |
147 |
-- {* The union of two finite sets is finite. *} |
|
22262 | 148 |
by (induct set: finite) simp_all |
12396 | 149 |
|
150 |
lemma finite_subset: "A \<subseteq> B ==> finite B ==> finite A" |
|
151 |
-- {* Every subset of a finite set is finite. *} |
|
152 |
proof - |
|
153 |
assume "finite B" |
|
154 |
thus "!!A. A \<subseteq> B ==> finite A" |
|
155 |
proof induct |
|
156 |
case empty |
|
157 |
thus ?case by simp |
|
158 |
next |
|
15327
0230a10582d3
changed the order of !!-quantifiers in finite set induction.
nipkow
parents:
15318
diff
changeset
|
159 |
case (insert x F A) |
23389 | 160 |
have A: "A \<subseteq> insert x F" and r: "A - {x} \<subseteq> F ==> finite (A - {x})" by fact+ |
12396 | 161 |
show "finite A" |
162 |
proof cases |
|
163 |
assume x: "x \<in> A" |
|
164 |
with A have "A - {x} \<subseteq> F" by (simp add: subset_insert_iff) |
|
165 |
with r have "finite (A - {x})" . |
|
166 |
hence "finite (insert x (A - {x}))" .. |
|
23389 | 167 |
also have "insert x (A - {x}) = A" using x by (rule insert_Diff) |
12396 | 168 |
finally show ?thesis . |
169 |
next |
|
23389 | 170 |
show "A \<subseteq> F ==> ?thesis" by fact |
12396 | 171 |
assume "x \<notin> A" |
172 |
with A show "A \<subseteq> F" by (simp add: subset_insert_iff) |
|
173 |
qed |
|
174 |
qed |
|
175 |
qed |
|
176 |
||
18423 | 177 |
lemma finite_Collect_subset[simp]: "finite A \<Longrightarrow> finite{x \<in> A. P x}" |
17761 | 178 |
using finite_subset[of "{x \<in> A. P x}" "A"] by blast |
179 |
||
12396 | 180 |
lemma finite_Un [iff]: "finite (F Un G) = (finite F & finite G)" |
181 |
by (blast intro: finite_subset [of _ "X Un Y", standard] finite_UnI) |
|
182 |
||
183 |
lemma finite_Int [simp, intro]: "finite F | finite G ==> finite (F Int G)" |
|
184 |
-- {* The converse obviously fails. *} |
|
185 |
by (blast intro: finite_subset) |
|
186 |
||
187 |
lemma finite_insert [simp]: "finite (insert a A) = finite A" |
|
188 |
apply (subst insert_is_Un) |
|
14208 | 189 |
apply (simp only: finite_Un, blast) |
12396 | 190 |
done |
191 |
||
15281 | 192 |
lemma finite_Union[simp, intro]: |
193 |
"\<lbrakk> finite A; !!M. M \<in> A \<Longrightarrow> finite M \<rbrakk> \<Longrightarrow> finite(\<Union>A)" |
|
194 |
by (induct rule:finite_induct) simp_all |
|
195 |
||
12396 | 196 |
lemma finite_empty_induct: |
23389 | 197 |
assumes "finite A" |
198 |
and "P A" |
|
199 |
and "!!a A. finite A ==> a:A ==> P A ==> P (A - {a})" |
|
200 |
shows "P {}" |
|
12396 | 201 |
proof - |
202 |
have "P (A - A)" |
|
203 |
proof - |
|
23389 | 204 |
{ |
205 |
fix c b :: "'a set" |
|
206 |
assume c: "finite c" and b: "finite b" |
|
207 |
and P1: "P b" and P2: "!!x y. finite y ==> x \<in> y ==> P y ==> P (y - {x})" |
|
208 |
have "c \<subseteq> b ==> P (b - c)" |
|
209 |
using c |
|
210 |
proof induct |
|
211 |
case empty |
|
212 |
from P1 show ?case by simp |
|
213 |
next |
|
214 |
case (insert x F) |
|
215 |
have "P (b - F - {x})" |
|
216 |
proof (rule P2) |
|
217 |
from _ b show "finite (b - F)" by (rule finite_subset) blast |
|
218 |
from insert show "x \<in> b - F" by simp |
|
219 |
from insert show "P (b - F)" by simp |
|
220 |
qed |
|
221 |
also have "b - F - {x} = b - insert x F" by (rule Diff_insert [symmetric]) |
|
222 |
finally show ?case . |
|
12396 | 223 |
qed |
23389 | 224 |
} |
225 |
then show ?thesis by this (simp_all add: assms) |
|
12396 | 226 |
qed |
23389 | 227 |
then show ?thesis by simp |
12396 | 228 |
qed |
229 |
||
230 |
lemma finite_Diff [simp]: "finite B ==> finite (B - Ba)" |
|
231 |
by (rule Diff_subset [THEN finite_subset]) |
|
232 |
||
233 |
lemma finite_Diff_insert [iff]: "finite (A - insert a B) = finite (A - B)" |
|
234 |
apply (subst Diff_insert) |
|
235 |
apply (case_tac "a : A - B") |
|
236 |
apply (rule finite_insert [symmetric, THEN trans]) |
|
14208 | 237 |
apply (subst insert_Diff, simp_all) |
12396 | 238 |
done |
239 |
||
19870 | 240 |
lemma finite_Diff_singleton [simp]: "finite (A - {a}) = finite A" |
241 |
by simp |
|
242 |
||
12396 | 243 |
|
15392 | 244 |
text {* Image and Inverse Image over Finite Sets *} |
13825 | 245 |
|
246 |
lemma finite_imageI[simp]: "finite F ==> finite (h ` F)" |
|
247 |
-- {* The image of a finite set is finite. *} |
|
22262 | 248 |
by (induct set: finite) simp_all |
13825 | 249 |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
250 |
lemma finite_surj: "finite A ==> B <= f ` A ==> finite B" |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
251 |
apply (frule finite_imageI) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
252 |
apply (erule finite_subset, assumption) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
253 |
done |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
254 |
|
13825 | 255 |
lemma finite_range_imageI: |
256 |
"finite (range g) ==> finite (range (%x. f (g x)))" |
|
27418 | 257 |
apply (drule finite_imageI, simp add: range_composition) |
13825 | 258 |
done |
259 |
||
12396 | 260 |
lemma finite_imageD: "finite (f`A) ==> inj_on f A ==> finite A" |
261 |
proof - |
|
262 |
have aux: "!!A. finite (A - {}) = finite A" by simp |
|
263 |
fix B :: "'a set" |
|
264 |
assume "finite B" |
|
265 |
thus "!!A. f`A = B ==> inj_on f A ==> finite A" |
|
266 |
apply induct |
|
267 |
apply simp |
|
268 |
apply (subgoal_tac "EX y:A. f y = x & F = f ` (A - {y})") |
|
269 |
apply clarify |
|
270 |
apply (simp (no_asm_use) add: inj_on_def) |
|
14208 | 271 |
apply (blast dest!: aux [THEN iffD1], atomize) |
12396 | 272 |
apply (erule_tac V = "ALL A. ?PP (A)" in thin_rl) |
14208 | 273 |
apply (frule subsetD [OF equalityD2 insertI1], clarify) |
12396 | 274 |
apply (rule_tac x = xa in bexI) |
275 |
apply (simp_all add: inj_on_image_set_diff) |
|
276 |
done |
|
277 |
qed (rule refl) |
|
278 |
||
279 |
||
13825 | 280 |
lemma inj_vimage_singleton: "inj f ==> f-`{a} \<subseteq> {THE x. f x = a}" |
281 |
-- {* The inverse image of a singleton under an injective function |
|
282 |
is included in a singleton. *} |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
283 |
apply (auto simp add: inj_on_def) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
284 |
apply (blast intro: the_equality [symmetric]) |
13825 | 285 |
done |
286 |
||
287 |
lemma finite_vimageI: "[|finite F; inj h|] ==> finite (h -` F)" |
|
288 |
-- {* The inverse image of a finite set under an injective function |
|
289 |
is finite. *} |
|
22262 | 290 |
apply (induct set: finite) |
21575 | 291 |
apply simp_all |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
292 |
apply (subst vimage_insert) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
293 |
apply (simp add: finite_Un finite_subset [OF inj_vimage_singleton]) |
13825 | 294 |
done |
295 |
||
296 |
||
15392 | 297 |
text {* The finite UNION of finite sets *} |
12396 | 298 |
|
299 |
lemma finite_UN_I: "finite A ==> (!!a. a:A ==> finite (B a)) ==> finite (UN a:A. B a)" |
|
22262 | 300 |
by (induct set: finite) simp_all |
12396 | 301 |
|
302 |
text {* |
|
303 |
Strengthen RHS to |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
304 |
@{prop "((ALL x:A. finite (B x)) & finite {x. x:A & B x \<noteq> {}})"}? |
12396 | 305 |
|
306 |
We'd need to prove |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
307 |
@{prop "finite C ==> ALL A B. (UNION A B) <= C --> finite {x. x:A & B x \<noteq> {}}"} |
12396 | 308 |
by induction. *} |
309 |
||
310 |
lemma finite_UN [simp]: "finite A ==> finite (UNION A B) = (ALL x:A. finite (B x))" |
|
311 |
by (blast intro: finite_UN_I finite_subset) |
|
312 |
||
313 |
||
17022 | 314 |
lemma finite_Plus: "[| finite A; finite B |] ==> finite (A <+> B)" |
315 |
by (simp add: Plus_def) |
|
316 |
||
15392 | 317 |
text {* Sigma of finite sets *} |
12396 | 318 |
|
319 |
lemma finite_SigmaI [simp]: |
|
320 |
"finite A ==> (!!a. a:A ==> finite (B a)) ==> finite (SIGMA a:A. B a)" |
|
321 |
by (unfold Sigma_def) (blast intro!: finite_UN_I) |
|
322 |
||
15402 | 323 |
lemma finite_cartesian_product: "[| finite A; finite B |] ==> |
324 |
finite (A <*> B)" |
|
325 |
by (rule finite_SigmaI) |
|
326 |
||
12396 | 327 |
lemma finite_Prod_UNIV: |
328 |
"finite (UNIV::'a set) ==> finite (UNIV::'b set) ==> finite (UNIV::('a * 'b) set)" |
|
329 |
apply (subgoal_tac "(UNIV:: ('a * 'b) set) = Sigma UNIV (%x. UNIV)") |
|
330 |
apply (erule ssubst) |
|
14208 | 331 |
apply (erule finite_SigmaI, auto) |
12396 | 332 |
done |
333 |
||
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
334 |
lemma finite_cartesian_productD1: |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
335 |
"[| finite (A <*> B); B \<noteq> {} |] ==> finite A" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
336 |
apply (auto simp add: finite_conv_nat_seg_image) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
337 |
apply (drule_tac x=n in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
338 |
apply (drule_tac x="fst o f" in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
339 |
apply (auto simp add: o_def) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
340 |
prefer 2 apply (force dest!: equalityD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
341 |
apply (drule equalityD1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
342 |
apply (rename_tac y x) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
343 |
apply (subgoal_tac "\<exists>k. k<n & f k = (x,y)") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
344 |
prefer 2 apply force |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
345 |
apply clarify |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
346 |
apply (rule_tac x=k in image_eqI, auto) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
347 |
done |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
348 |
|
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
349 |
lemma finite_cartesian_productD2: |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
350 |
"[| finite (A <*> B); A \<noteq> {} |] ==> finite B" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
351 |
apply (auto simp add: finite_conv_nat_seg_image) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
352 |
apply (drule_tac x=n in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
353 |
apply (drule_tac x="snd o f" in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
354 |
apply (auto simp add: o_def) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
355 |
prefer 2 apply (force dest!: equalityD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
356 |
apply (drule equalityD1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
357 |
apply (rename_tac x y) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
358 |
apply (subgoal_tac "\<exists>k. k<n & f k = (x,y)") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
359 |
prefer 2 apply force |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
360 |
apply clarify |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
361 |
apply (rule_tac x=k in image_eqI, auto) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
362 |
done |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
363 |
|
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
364 |
|
15392 | 365 |
text {* The powerset of a finite set *} |
12396 | 366 |
|
367 |
lemma finite_Pow_iff [iff]: "finite (Pow A) = finite A" |
|
368 |
proof |
|
369 |
assume "finite (Pow A)" |
|
370 |
with _ have "finite ((%x. {x}) ` A)" by (rule finite_subset) blast |
|
371 |
thus "finite A" by (rule finite_imageD [unfolded inj_on_def]) simp |
|
372 |
next |
|
373 |
assume "finite A" |
|
374 |
thus "finite (Pow A)" |
|
375 |
by induct (simp_all add: finite_UnI finite_imageI Pow_insert) |
|
376 |
qed |
|
377 |
||
15392 | 378 |
|
379 |
lemma finite_UnionD: "finite(\<Union>A) \<Longrightarrow> finite A" |
|
380 |
by(blast intro: finite_subset[OF subset_Pow_Union]) |
|
381 |
||
382 |
||
12396 | 383 |
lemma finite_converse [iff]: "finite (r^-1) = finite r" |
384 |
apply (subgoal_tac "r^-1 = (%(x,y). (y,x))`r") |
|
385 |
apply simp |
|
386 |
apply (rule iffI) |
|
387 |
apply (erule finite_imageD [unfolded inj_on_def]) |
|
388 |
apply (simp split add: split_split) |
|
389 |
apply (erule finite_imageI) |
|
14208 | 390 |
apply (simp add: converse_def image_def, auto) |
12396 | 391 |
apply (rule bexI) |
392 |
prefer 2 apply assumption |
|
393 |
apply simp |
|
394 |
done |
|
395 |
||
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
396 |
|
15392 | 397 |
text {* \paragraph{Finiteness of transitive closure} (Thanks to Sidi |
398 |
Ehmety) *} |
|
12396 | 399 |
|
400 |
lemma finite_Field: "finite r ==> finite (Field r)" |
|
401 |
-- {* A finite relation has a finite field (@{text "= domain \<union> range"}. *} |
|
22262 | 402 |
apply (induct set: finite) |
12396 | 403 |
apply (auto simp add: Field_def Domain_insert Range_insert) |
404 |
done |
|
405 |
||
406 |
lemma trancl_subset_Field2: "r^+ <= Field r \<times> Field r" |
|
407 |
apply clarify |
|
408 |
apply (erule trancl_induct) |
|
409 |
apply (auto simp add: Field_def) |
|
410 |
done |
|
411 |
||
412 |
lemma finite_trancl: "finite (r^+) = finite r" |
|
413 |
apply auto |
|
414 |
prefer 2 |
|
415 |
apply (rule trancl_subset_Field2 [THEN finite_subset]) |
|
416 |
apply (rule finite_SigmaI) |
|
417 |
prefer 3 |
|
13704
854501b1e957
Transitive closure is now defined inductively as well.
berghofe
parents:
13595
diff
changeset
|
418 |
apply (blast intro: r_into_trancl' finite_subset) |
12396 | 419 |
apply (auto simp add: finite_Field) |
420 |
done |
|
421 |
||
422 |
||
26441 | 423 |
subsection {* Class @{text finite} *} |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
424 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
425 |
setup {* Sign.add_path "finite" *} -- {*FIXME: name tweaking*} |
26441 | 426 |
class finite = itself + |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
427 |
assumes finite_UNIV: "finite (UNIV \<Colon> 'a set)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
428 |
setup {* Sign.parent_path *} |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
429 |
hide const finite |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
430 |
|
27430 | 431 |
context finite |
432 |
begin |
|
433 |
||
434 |
lemma finite [simp]: "finite (A \<Colon> 'a set)" |
|
26441 | 435 |
by (rule subset_UNIV finite_UNIV finite_subset)+ |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
436 |
|
27430 | 437 |
end |
438 |
||
26146 | 439 |
lemma UNIV_unit [noatp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
440 |
"UNIV = {()}" by auto |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
441 |
|
26146 | 442 |
instance unit :: finite |
443 |
by default (simp add: UNIV_unit) |
|
444 |
||
445 |
lemma UNIV_bool [noatp]: |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
446 |
"UNIV = {False, True}" by auto |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
447 |
|
26146 | 448 |
instance bool :: finite |
449 |
by default (simp add: UNIV_bool) |
|
450 |
||
451 |
instance * :: (finite, finite) finite |
|
452 |
by default (simp only: UNIV_Times_UNIV [symmetric] finite_cartesian_product finite) |
|
453 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
454 |
lemma inj_graph: "inj (%f. {(x, y). y = f x})" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
455 |
by (rule inj_onI, auto simp add: expand_set_eq expand_fun_eq) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
456 |
|
26146 | 457 |
instance "fun" :: (finite, finite) finite |
458 |
proof |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
459 |
show "finite (UNIV :: ('a => 'b) set)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
460 |
proof (rule finite_imageD) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
461 |
let ?graph = "%f::'a => 'b. {(x, y). y = f x}" |
26792 | 462 |
have "range ?graph \<subseteq> Pow UNIV" by simp |
463 |
moreover have "finite (Pow (UNIV :: ('a * 'b) set))" |
|
464 |
by (simp only: finite_Pow_iff finite) |
|
465 |
ultimately show "finite (range ?graph)" |
|
466 |
by (rule finite_subset) |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
467 |
show "inj ?graph" by (rule inj_graph) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
468 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
469 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
470 |
|
27981 | 471 |
instance "+" :: (finite, finite) finite |
472 |
by default (simp only: UNIV_Plus_UNIV [symmetric] finite_Plus finite) |
|
473 |
||
474 |
instance option :: (finite) finite |
|
475 |
by default (simp add: insert_None_conv_UNIV [symmetric]) |
|
476 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
477 |
|
15392 | 478 |
subsection {* A fold functional for finite sets *} |
479 |
||
480 |
text {* The intended behaviour is |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
481 |
@{text "fold f z {x\<^isub>1, ..., x\<^isub>n} = f x\<^isub>1 (\<dots> (f x\<^isub>n z)\<dots>)"} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
482 |
if @{text f} is ``left-commutative'': |
15392 | 483 |
*} |
484 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
485 |
locale fun_left_comm = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
486 |
fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> 'b" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
487 |
assumes fun_left_comm: "f x (f y z) = f y (f x z)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
488 |
begin |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
489 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
490 |
text{* On a functional level it looks much nicer: *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
491 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
492 |
lemma fun_comp_comm: "f x \<circ> f y = f y \<circ> f x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
493 |
by (simp add: fun_left_comm expand_fun_eq) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
494 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
495 |
end |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
496 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
497 |
inductive fold_graph :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> bool" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
498 |
for f :: "'a \<Rightarrow> 'b \<Rightarrow> 'b" and z :: 'b where |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
499 |
emptyI [intro]: "fold_graph f z {} z" | |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
500 |
insertI [intro]: "x \<notin> A \<Longrightarrow> fold_graph f z A y |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
501 |
\<Longrightarrow> fold_graph f z (insert x A) (f x y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
502 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
503 |
inductive_cases empty_fold_graphE [elim!]: "fold_graph f z {} x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
504 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
505 |
definition fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b" where |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
506 |
[code del]: "fold f z A = (THE y. fold_graph f z A y)" |
15392 | 507 |
|
15498 | 508 |
text{*A tempting alternative for the definiens is |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
509 |
@{term "if finite A then THE y. fold_graph f z A y else e"}. |
15498 | 510 |
It allows the removal of finiteness assumptions from the theorems |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
511 |
@{text fold_comm}, @{text fold_reindex} and @{text fold_distrib}. |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
512 |
The proofs become ugly. It is not worth the effort. (???) *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
513 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
514 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
515 |
lemma Diff1_fold_graph: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
516 |
"fold_graph f z (A - {x}) y \<Longrightarrow> x \<in> A \<Longrightarrow> fold_graph f z A (f x y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
517 |
by (erule insert_Diff [THEN subst], rule fold_graph.intros, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
518 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
519 |
lemma fold_graph_imp_finite: "fold_graph f z A x \<Longrightarrow> finite A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
520 |
by (induct set: fold_graph) auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
521 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
522 |
lemma finite_imp_fold_graph: "finite A \<Longrightarrow> \<exists>x. fold_graph f z A x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
523 |
by (induct set: finite) auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
524 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
525 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
526 |
subsubsection{*From @{const fold_graph} to @{term fold}*} |
15392 | 527 |
|
15510 | 528 |
lemma image_less_Suc: "h ` {i. i < Suc m} = insert (h m) (h ` {i. i < m})" |
19868 | 529 |
by (auto simp add: less_Suc_eq) |
15510 | 530 |
|
531 |
lemma insert_image_inj_on_eq: |
|
532 |
"[|insert (h m) A = h ` {i. i < Suc m}; h m \<notin> A; |
|
533 |
inj_on h {i. i < Suc m}|] |
|
534 |
==> A = h ` {i. i < m}" |
|
535 |
apply (auto simp add: image_less_Suc inj_on_def) |
|
536 |
apply (blast intro: less_trans) |
|
537 |
done |
|
538 |
||
539 |
lemma insert_inj_onE: |
|
540 |
assumes aA: "insert a A = h`{i::nat. i<n}" and anot: "a \<notin> A" |
|
541 |
and inj_on: "inj_on h {i::nat. i<n}" |
|
542 |
shows "\<exists>hm m. inj_on hm {i::nat. i<m} & A = hm ` {i. i<m} & m < n" |
|
543 |
proof (cases n) |
|
544 |
case 0 thus ?thesis using aA by auto |
|
545 |
next |
|
546 |
case (Suc m) |
|
23389 | 547 |
have nSuc: "n = Suc m" by fact |
15510 | 548 |
have mlessn: "m<n" by (simp add: nSuc) |
15532 | 549 |
from aA obtain k where hkeq: "h k = a" and klessn: "k<n" by (blast elim!: equalityE) |
27165 | 550 |
let ?hm = "Fun.swap k m h" |
15520 | 551 |
have inj_hm: "inj_on ?hm {i. i < n}" using klessn mlessn |
552 |
by (simp add: inj_on_swap_iff inj_on) |
|
15510 | 553 |
show ?thesis |
15520 | 554 |
proof (intro exI conjI) |
555 |
show "inj_on ?hm {i. i < m}" using inj_hm |
|
15510 | 556 |
by (auto simp add: nSuc less_Suc_eq intro: subset_inj_on) |
15520 | 557 |
show "m<n" by (rule mlessn) |
558 |
show "A = ?hm ` {i. i < m}" |
|
559 |
proof (rule insert_image_inj_on_eq) |
|
27165 | 560 |
show "inj_on (Fun.swap k m h) {i. i < Suc m}" using inj_hm nSuc by simp |
15520 | 561 |
show "?hm m \<notin> A" by (simp add: swap_def hkeq anot) |
562 |
show "insert (?hm m) A = ?hm ` {i. i < Suc m}" |
|
563 |
using aA hkeq nSuc klessn |
|
564 |
by (auto simp add: swap_def image_less_Suc fun_upd_image |
|
565 |
less_Suc_eq inj_on_image_set_diff [OF inj_on]) |
|
15479 | 566 |
qed |
567 |
qed |
|
568 |
qed |
|
569 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
570 |
context fun_left_comm |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
571 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
572 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
573 |
lemma fold_graph_determ_aux: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
574 |
"A = h`{i::nat. i<n} \<Longrightarrow> inj_on h {i. i<n} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
575 |
\<Longrightarrow> fold_graph f z A x \<Longrightarrow> fold_graph f z A x' |
15392 | 576 |
\<Longrightarrow> x' = x" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
577 |
proof (induct n arbitrary: A x x' h rule: less_induct) |
15510 | 578 |
case (less n) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
579 |
have IH: "\<And>m h A x x'. m < n \<Longrightarrow> A = h ` {i. i<m} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
580 |
\<Longrightarrow> inj_on h {i. i<m} \<Longrightarrow> fold_graph f z A x |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
581 |
\<Longrightarrow> fold_graph f z A x' \<Longrightarrow> x' = x" by fact |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
582 |
have Afoldx: "fold_graph f z A x" and Afoldx': "fold_graph f z A x'" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
583 |
and A: "A = h`{i. i<n}" and injh: "inj_on h {i. i<n}" by fact+ |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
584 |
show ?case |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
585 |
proof (rule fold_graph.cases [OF Afoldx]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
586 |
assume "A = {}" and "x = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
587 |
with Afoldx' show "x' = x" by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
588 |
next |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
589 |
fix B b u |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
590 |
assume AbB: "A = insert b B" and x: "x = f b u" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
591 |
and notinB: "b \<notin> B" and Bu: "fold_graph f z B u" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
592 |
show "x'=x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
593 |
proof (rule fold_graph.cases [OF Afoldx']) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
594 |
assume "A = {}" and "x' = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
595 |
with AbB show "x' = x" by blast |
15392 | 596 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
597 |
fix C c v |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
598 |
assume AcC: "A = insert c C" and x': "x' = f c v" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
599 |
and notinC: "c \<notin> C" and Cv: "fold_graph f z C v" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
600 |
from A AbB have Beq: "insert b B = h`{i. i<n}" by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
601 |
from insert_inj_onE [OF Beq notinB injh] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
602 |
obtain hB mB where inj_onB: "inj_on hB {i. i < mB}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
603 |
and Beq: "B = hB ` {i. i < mB}" and lessB: "mB < n" by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
604 |
from A AcC have Ceq: "insert c C = h`{i. i<n}" by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
605 |
from insert_inj_onE [OF Ceq notinC injh] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
606 |
obtain hC mC where inj_onC: "inj_on hC {i. i < mC}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
607 |
and Ceq: "C = hC ` {i. i < mC}" and lessC: "mC < n" by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
608 |
show "x'=x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
609 |
proof cases |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
610 |
assume "b=c" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
611 |
then moreover have "B = C" using AbB AcC notinB notinC by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
612 |
ultimately show ?thesis using Bu Cv x x' IH [OF lessC Ceq inj_onC] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
613 |
by auto |
15392 | 614 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
615 |
assume diff: "b \<noteq> c" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
616 |
let ?D = "B - {c}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
617 |
have B: "B = insert c ?D" and C: "C = insert b ?D" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
618 |
using AbB AcC notinB notinC diff by(blast elim!:equalityE)+ |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
619 |
have "finite A" by(rule fold_graph_imp_finite [OF Afoldx]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
620 |
with AbB have "finite ?D" by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
621 |
then obtain d where Dfoldd: "fold_graph f z ?D d" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
622 |
using finite_imp_fold_graph by iprover |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
623 |
moreover have cinB: "c \<in> B" using B by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
624 |
ultimately have "fold_graph f z B (f c d)" by(rule Diff1_fold_graph) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
625 |
hence "f c d = u" by (rule IH [OF lessB Beq inj_onB Bu]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
626 |
moreover have "f b d = v" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
627 |
proof (rule IH[OF lessC Ceq inj_onC Cv]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
628 |
show "fold_graph f z C (f b d)" using C notinB Dfoldd by fastsimp |
15392 | 629 |
qed |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
630 |
ultimately show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
631 |
using fun_left_comm [of c b] x x' by (auto simp add: o_def) |
15392 | 632 |
qed |
633 |
qed |
|
634 |
qed |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
635 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
636 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
637 |
lemma fold_graph_determ: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
638 |
"fold_graph f z A x \<Longrightarrow> fold_graph f z A y \<Longrightarrow> y = x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
639 |
apply (frule fold_graph_imp_finite [THEN finite_imp_nat_seg_image_inj_on]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
640 |
apply (blast intro: fold_graph_determ_aux [rule_format]) |
15392 | 641 |
done |
642 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
643 |
lemma fold_equality: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
644 |
"fold_graph f z A y \<Longrightarrow> fold f z A = y" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
645 |
by (unfold fold_def) (blast intro: fold_graph_determ) |
15392 | 646 |
|
647 |
text{* The base case for @{text fold}: *} |
|
648 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
649 |
lemma (in -) fold_empty [simp]: "fold f z {} = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
650 |
by (unfold fold_def) blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
651 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
652 |
text{* The various recursion equations for @{const fold}: *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
653 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
654 |
lemma fold_insert_aux: "x \<notin> A |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
655 |
\<Longrightarrow> fold_graph f z (insert x A) v \<longleftrightarrow> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
656 |
(\<exists>y. fold_graph f z A y \<and> v = f x y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
657 |
apply auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
658 |
apply (rule_tac A1 = A and f1 = f in finite_imp_fold_graph [THEN exE]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
659 |
apply (fastsimp dest: fold_graph_imp_finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
660 |
apply (blast intro: fold_graph_determ) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
661 |
done |
15392 | 662 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
663 |
lemma fold_insert [simp]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
664 |
"finite A ==> x \<notin> A ==> fold f z (insert x A) = f x (fold f z A)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
665 |
apply (simp add: fold_def fold_insert_aux) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
666 |
apply (rule the_equality) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
667 |
apply (auto intro: finite_imp_fold_graph |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
668 |
cong add: conj_cong simp add: fold_def[symmetric] fold_equality) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
669 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
670 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
671 |
lemma fold_fun_comm: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
672 |
"finite A \<Longrightarrow> f x (fold f z A) = fold f (f x z) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
673 |
proof (induct rule: finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
674 |
case empty then show ?case by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
675 |
next |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
676 |
case (insert y A) then show ?case |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
677 |
by (simp add: fun_left_comm[of x]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
678 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
679 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
680 |
lemma fold_insert2: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
681 |
"finite A \<Longrightarrow> x \<notin> A \<Longrightarrow> fold f z (insert x A) = fold f (f x z) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
682 |
by (simp add: fold_insert fold_fun_comm) |
15392 | 683 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
684 |
lemma fold_rec: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
685 |
assumes "finite A" and "x \<in> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
686 |
shows "fold f z A = f x (fold f z (A - {x}))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
687 |
proof - |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
688 |
have A: "A = insert x (A - {x})" using `x \<in> A` by blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
689 |
then have "fold f z A = fold f z (insert x (A - {x}))" by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
690 |
also have "\<dots> = f x (fold f z (A - {x}))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
691 |
by (rule fold_insert) (simp add: `finite A`)+ |
15535 | 692 |
finally show ?thesis . |
693 |
qed |
|
694 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
695 |
lemma fold_insert_remove: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
696 |
assumes "finite A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
697 |
shows "fold f z (insert x A) = f x (fold f z (A - {x}))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
698 |
proof - |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
699 |
from `finite A` have "finite (insert x A)" by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
700 |
moreover have "x \<in> insert x A" by auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
701 |
ultimately have "fold f z (insert x A) = f x (fold f z (insert x A - {x}))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
702 |
by (rule fold_rec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
703 |
then show ?thesis by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
704 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
705 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
706 |
end |
15392 | 707 |
|
15480 | 708 |
text{* A simplified version for idempotent functions: *} |
709 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
710 |
locale fun_left_comm_idem = fun_left_comm + |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
711 |
assumes fun_left_idem: "f x (f x z) = f x z" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
712 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
713 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
714 |
text{* The nice version: *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
715 |
lemma fun_comp_idem : "f x o f x = f x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
716 |
by (simp add: fun_left_idem expand_fun_eq) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
717 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
718 |
lemma fold_insert_idem: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
719 |
assumes fin: "finite A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
720 |
shows "fold f z (insert x A) = f x (fold f z A)" |
15480 | 721 |
proof cases |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
722 |
assume "x \<in> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
723 |
then obtain B where "A = insert x B" and "x \<notin> B" by (rule set_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
724 |
then show ?thesis using assms by (simp add:fun_left_idem) |
15480 | 725 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
726 |
assume "x \<notin> A" then show ?thesis using assms by simp |
15480 | 727 |
qed |
728 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
729 |
declare fold_insert[simp del] fold_insert_idem[simp] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
730 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
731 |
lemma fold_insert_idem2: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
732 |
"finite A \<Longrightarrow> fold f z (insert x A) = fold f (f x z) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
733 |
by(simp add:fold_fun_comm) |
15484 | 734 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
735 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
736 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
737 |
subsubsection{* The derived combinator @{text fold_image} *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
738 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
739 |
definition fold_image :: "('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
740 |
where "fold_image f g = fold (%x y. f (g x) y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
741 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
742 |
lemma fold_image_empty[simp]: "fold_image f g z {} = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
743 |
by(simp add:fold_image_def) |
15392 | 744 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
745 |
context ab_semigroup_mult |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
746 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
747 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
748 |
lemma fold_image_insert[simp]: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
749 |
assumes "finite A" and "a \<notin> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
750 |
shows "fold_image times g z (insert a A) = g a * (fold_image times g z A)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
751 |
proof - |
29223 | 752 |
interpret I: fun_left_comm "%x y. (g x) * y" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
753 |
by unfold_locales (simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
754 |
show ?thesis using assms by(simp add:fold_image_def I.fold_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
755 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
756 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
757 |
(* |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
758 |
lemma fold_commute: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
759 |
"finite A ==> (!!z. x * (fold times g z A) = fold times g (x * z) A)" |
22262 | 760 |
apply (induct set: finite) |
21575 | 761 |
apply simp |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
762 |
apply (simp add: mult_left_commute [of x]) |
15392 | 763 |
done |
764 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
765 |
lemma fold_nest_Un_Int: |
15392 | 766 |
"finite A ==> finite B |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
767 |
==> fold times g (fold times g z B) A = fold times g (fold times g z (A Int B)) (A Un B)" |
22262 | 768 |
apply (induct set: finite) |
21575 | 769 |
apply simp |
15392 | 770 |
apply (simp add: fold_commute Int_insert_left insert_absorb) |
771 |
done |
|
772 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
773 |
lemma fold_nest_Un_disjoint: |
15392 | 774 |
"finite A ==> finite B ==> A Int B = {} |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
775 |
==> fold times g z (A Un B) = fold times g (fold times g z B) A" |
15392 | 776 |
by (simp add: fold_nest_Un_Int) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
777 |
*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
778 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
779 |
lemma fold_image_reindex: |
15487 | 780 |
assumes fin: "finite A" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
781 |
shows "inj_on h A \<Longrightarrow> fold_image times g z (h`A) = fold_image times (g\<circ>h) z A" |
15506 | 782 |
using fin apply induct |
15392 | 783 |
apply simp |
784 |
apply simp |
|
785 |
done |
|
786 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
787 |
(* |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
788 |
text{* |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
789 |
Fusion theorem, as described in Graham Hutton's paper, |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
790 |
A Tutorial on the Universality and Expressiveness of Fold, |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
791 |
JFP 9:4 (355-372), 1999. |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
792 |
*} |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
793 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
794 |
lemma fold_fusion: |
27611 | 795 |
assumes "ab_semigroup_mult g" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
796 |
assumes fin: "finite A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
797 |
and hyp: "\<And>x y. h (g x y) = times x (h y)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
798 |
shows "h (fold g j w A) = fold times j (h w) A" |
27611 | 799 |
proof - |
29223 | 800 |
class_interpret ab_semigroup_mult [g] by fact |
27611 | 801 |
show ?thesis using fin hyp by (induct set: finite) simp_all |
802 |
qed |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
803 |
*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
804 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
805 |
lemma fold_image_cong: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
806 |
"finite A \<Longrightarrow> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
807 |
(!!x. x:A ==> g x = h x) ==> fold_image times g z A = fold_image times h z A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
808 |
apply (subgoal_tac "ALL C. C <= A --> (ALL x:C. g x = h x) --> fold_image times g z C = fold_image times h z C") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
809 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
810 |
apply (erule finite_induct, simp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
811 |
apply (simp add: subset_insert_iff, clarify) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
812 |
apply (subgoal_tac "finite C") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
813 |
prefer 2 apply (blast dest: finite_subset [COMP swap_prems_rl]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
814 |
apply (subgoal_tac "C = insert x (C - {x})") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
815 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
816 |
apply (erule ssubst) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
817 |
apply (drule spec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
818 |
apply (erule (1) notE impE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
819 |
apply (simp add: Ball_def del: insert_Diff_single) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
820 |
done |
15392 | 821 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
822 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
823 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
824 |
context comm_monoid_mult |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
825 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
826 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
827 |
lemma fold_image_Un_Int: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
828 |
"finite A ==> finite B ==> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
829 |
fold_image times g 1 A * fold_image times g 1 B = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
830 |
fold_image times g 1 (A Un B) * fold_image times g 1 (A Int B)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
831 |
by (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
832 |
(auto simp add: mult_ac insert_absorb Int_insert_left) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
833 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
834 |
corollary fold_Un_disjoint: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
835 |
"finite A ==> finite B ==> A Int B = {} ==> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
836 |
fold_image times g 1 (A Un B) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
837 |
fold_image times g 1 A * fold_image times g 1 B" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
838 |
by (simp add: fold_image_Un_Int) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
839 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
840 |
lemma fold_image_UN_disjoint: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
841 |
"\<lbrakk> finite I; ALL i:I. finite (A i); |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
842 |
ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {} \<rbrakk> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
843 |
\<Longrightarrow> fold_image times g 1 (UNION I A) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
844 |
fold_image times (%i. fold_image times g 1 (A i)) 1 I" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
845 |
apply (induct set: finite, simp, atomize) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
846 |
apply (subgoal_tac "ALL i:F. x \<noteq> i") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
847 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
848 |
apply (subgoal_tac "A x Int UNION F A = {}") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
849 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
850 |
apply (simp add: fold_Un_disjoint) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
851 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
852 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
853 |
lemma fold_image_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
854 |
fold_image times (%x. fold_image times (g x) 1 (B x)) 1 A = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
855 |
fold_image times (split g) 1 (SIGMA x:A. B x)" |
15392 | 856 |
apply (subst Sigma_def) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
857 |
apply (subst fold_image_UN_disjoint, assumption, simp) |
15392 | 858 |
apply blast |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
859 |
apply (erule fold_image_cong) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
860 |
apply (subst fold_image_UN_disjoint, simp, simp) |
15392 | 861 |
apply blast |
15506 | 862 |
apply simp |
15392 | 863 |
done |
864 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
865 |
lemma fold_image_distrib: "finite A \<Longrightarrow> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
866 |
fold_image times (%x. g x * h x) 1 A = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
867 |
fold_image times g 1 A * fold_image times h 1 A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
868 |
by (erule finite_induct) (simp_all add: mult_ac) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
869 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
870 |
end |
22917 | 871 |
|
872 |
||
15402 | 873 |
subsection {* Generalized summation over a set *} |
874 |
||
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
875 |
interpretation comm_monoid_add!: comm_monoid_mult "0::'a::comm_monoid_add" "op +" |
28823 | 876 |
proof qed (auto intro: add_assoc add_commute) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
877 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
878 |
definition setsum :: "('a => 'b) => 'a set => 'b::comm_monoid_add" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
879 |
where "setsum f A == if finite A then fold_image (op +) f 0 A else 0" |
15402 | 880 |
|
19535 | 881 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
882 |
Setsum ("\<Sum>_" [1000] 999) where |
19535 | 883 |
"\<Sum>A == setsum (%x. x) A" |
884 |
||
15402 | 885 |
text{* Now: lot's of fancy syntax. First, @{term "setsum (%x. e) A"} is |
886 |
written @{text"\<Sum>x\<in>A. e"}. *} |
|
887 |
||
888 |
syntax |
|
17189 | 889 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3SUM _:_. _)" [0, 51, 10] 10) |
15402 | 890 |
syntax (xsymbols) |
17189 | 891 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 892 |
syntax (HTML output) |
17189 | 893 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 894 |
|
895 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
896 |
"SUM i:A. b" == "CONST setsum (%i. b) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
897 |
"\<Sum>i\<in>A. b" == "CONST setsum (%i. b) A" |
15402 | 898 |
|
899 |
text{* Instead of @{term"\<Sum>x\<in>{x. P}. e"} we introduce the shorter |
|
900 |
@{text"\<Sum>x|P. e"}. *} |
|
901 |
||
902 |
syntax |
|
17189 | 903 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3SUM _ |/ _./ _)" [0,0,10] 10) |
15402 | 904 |
syntax (xsymbols) |
17189 | 905 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 906 |
syntax (HTML output) |
17189 | 907 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 908 |
|
909 |
translations |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
910 |
"SUM x|P. t" => "CONST setsum (%x. t) {x. P}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
911 |
"\<Sum>x|P. t" => "CONST setsum (%x. t) {x. P}" |
15402 | 912 |
|
913 |
print_translation {* |
|
914 |
let |
|
19535 | 915 |
fun setsum_tr' [Abs(x,Tx,t), Const ("Collect",_) $ Abs(y,Ty,P)] = |
916 |
if x<>y then raise Match |
|
917 |
else let val x' = Syntax.mark_bound x |
|
918 |
val t' = subst_bound(x',t) |
|
919 |
val P' = subst_bound(x',P) |
|
920 |
in Syntax.const "_qsetsum" $ Syntax.mark_bound x $ P' $ t' end |
|
921 |
in [("setsum", setsum_tr')] end |
|
15402 | 922 |
*} |
923 |
||
19535 | 924 |
|
15402 | 925 |
lemma setsum_empty [simp]: "setsum f {} = 0" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
926 |
by (simp add: setsum_def) |
15402 | 927 |
|
928 |
lemma setsum_insert [simp]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
929 |
"finite F ==> a \<notin> F ==> setsum f (insert a F) = f a + setsum f F" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
930 |
by (simp add: setsum_def) |
15402 | 931 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
932 |
lemma setsum_infinite [simp]: "~ finite A ==> setsum f A = 0" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
933 |
by (simp add: setsum_def) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
934 |
|
15402 | 935 |
lemma setsum_reindex: |
936 |
"inj_on f B ==> setsum h (f ` B) = setsum (h \<circ> f) B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
937 |
by(auto simp add: setsum_def comm_monoid_add.fold_image_reindex dest!:finite_imageD) |
15402 | 938 |
|
939 |
lemma setsum_reindex_id: |
|
940 |
"inj_on f B ==> setsum f B = setsum id (f ` B)" |
|
941 |
by (auto simp add: setsum_reindex) |
|
942 |
||
943 |
lemma setsum_cong: |
|
944 |
"A = B ==> (!!x. x:B ==> f x = g x) ==> setsum f A = setsum g B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
945 |
by(fastsimp simp: setsum_def intro: comm_monoid_add.fold_image_cong) |
15402 | 946 |
|
16733
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
947 |
lemma strong_setsum_cong[cong]: |
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
948 |
"A = B ==> (!!x. x:B =simp=> f x = g x) |
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
949 |
==> setsum (%x. f x) A = setsum (%x. g x) B" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
950 |
by(fastsimp simp: simp_implies_def setsum_def intro: comm_monoid_add.fold_image_cong) |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
951 |
|
15554 | 952 |
lemma setsum_cong2: "\<lbrakk>\<And>x. x \<in> A \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> setsum f A = setsum g A"; |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
953 |
by (rule setsum_cong[OF refl], auto); |
15554 | 954 |
|
15402 | 955 |
lemma setsum_reindex_cong: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
956 |
"[|inj_on f A; B = f ` A; !!a. a:A \<Longrightarrow> g a = h (f a)|] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
957 |
==> setsum h B = setsum g A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
958 |
by (simp add: setsum_reindex cong: setsum_cong) |
15402 | 959 |
|
15542 | 960 |
lemma setsum_0[simp]: "setsum (%i. 0) A = 0" |
15402 | 961 |
apply (clarsimp simp: setsum_def) |
15765 | 962 |
apply (erule finite_induct, auto) |
15402 | 963 |
done |
964 |
||
15543 | 965 |
lemma setsum_0': "ALL a:A. f a = 0 ==> setsum f A = 0" |
966 |
by(simp add:setsum_cong) |
|
15402 | 967 |
|
968 |
lemma setsum_Un_Int: "finite A ==> finite B ==> |
|
969 |
setsum g (A Un B) + setsum g (A Int B) = setsum g A + setsum g B" |
|
970 |
-- {* The reversed orientation looks more natural, but LOOPS as a simprule! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
971 |
by(simp add: setsum_def comm_monoid_add.fold_image_Un_Int [symmetric]) |
15402 | 972 |
|
973 |
lemma setsum_Un_disjoint: "finite A ==> finite B |
|
974 |
==> A Int B = {} ==> setsum g (A Un B) = setsum g A + setsum g B" |
|
975 |
by (subst setsum_Un_Int [symmetric], auto) |
|
976 |
||
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
977 |
(*But we can't get rid of finite I. If infinite, although the rhs is 0, |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
978 |
the lhs need not be, since UNION I A could still be finite.*) |
15402 | 979 |
lemma setsum_UN_disjoint: |
980 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
|
981 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==> |
|
982 |
setsum f (UNION I A) = (\<Sum>i\<in>I. setsum f (A i))" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
983 |
by(simp add: setsum_def comm_monoid_add.fold_image_UN_disjoint cong: setsum_cong) |
15402 | 984 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
985 |
text{*No need to assume that @{term C} is finite. If infinite, the rhs is |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
986 |
directly 0, and @{term "Union C"} is also infinite, hence the lhs is also 0.*} |
15402 | 987 |
lemma setsum_Union_disjoint: |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
988 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
989 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |] |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
990 |
==> setsum f (Union C) = setsum (setsum f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
991 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
992 |
prefer 2 apply (force dest: finite_UnionD simp add: setsum_def) |
15402 | 993 |
apply (frule setsum_UN_disjoint [of C id f]) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
994 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
995 |
done |
15402 | 996 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
997 |
(*But we can't get rid of finite A. If infinite, although the lhs is 0, |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
998 |
the rhs need not be, since SIGMA A B could still be finite.*) |
15402 | 999 |
lemma setsum_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
17189 | 1000 |
(\<Sum>x\<in>A. (\<Sum>y\<in>B x. f x y)) = (\<Sum>(x,y)\<in>(SIGMA x:A. B x). f x y)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1001 |
by(simp add:setsum_def comm_monoid_add.fold_image_Sigma split_def cong:setsum_cong) |
15402 | 1002 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1003 |
text{*Here we can eliminate the finiteness assumptions, by cases.*} |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1004 |
lemma setsum_cartesian_product: |
17189 | 1005 |
"(\<Sum>x\<in>A. (\<Sum>y\<in>B. f x y)) = (\<Sum>(x,y) \<in> A <*> B. f x y)" |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1006 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1007 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1008 |
apply (simp add: setsum_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1009 |
apply (cases "A={}", simp) |
15543 | 1010 |
apply (simp) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1011 |
apply (auto simp add: setsum_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1012 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1013 |
done |
15402 | 1014 |
|
1015 |
lemma setsum_addf: "setsum (%x. f x + g x) A = (setsum f A + setsum g A)" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1016 |
by(simp add:setsum_def comm_monoid_add.fold_image_distrib) |
15402 | 1017 |
|
1018 |
||
1019 |
subsubsection {* Properties in more restricted classes of structures *} |
|
1020 |
||
1021 |
lemma setsum_SucD: "setsum f A = Suc n ==> EX a:A. 0 < f a" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1022 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1023 |
prefer 2 apply (simp add: setsum_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1024 |
apply (erule rev_mp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1025 |
apply (erule finite_induct, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1026 |
done |
15402 | 1027 |
|
1028 |
lemma setsum_eq_0_iff [simp]: |
|
1029 |
"finite F ==> (setsum f F = 0) = (ALL a:F. f a = (0::nat))" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1030 |
by (induct set: finite) auto |
15402 | 1031 |
|
1032 |
lemma setsum_Un_nat: "finite A ==> finite B ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1033 |
(setsum f (A Un B) :: nat) = setsum f A + setsum f B - setsum f (A Int B)" |
15402 | 1034 |
-- {* For the natural numbers, we have subtraction. *} |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1035 |
by (subst setsum_Un_Int [symmetric], auto simp add: ring_simps) |
15402 | 1036 |
|
1037 |
lemma setsum_Un: "finite A ==> finite B ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1038 |
(setsum f (A Un B) :: 'a :: ab_group_add) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1039 |
setsum f A + setsum f B - setsum f (A Int B)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1040 |
by (subst setsum_Un_Int [symmetric], auto simp add: ring_simps) |
15402 | 1041 |
|
1042 |
lemma setsum_diff1_nat: "(setsum f (A - {a}) :: nat) = |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1043 |
(if a:A then setsum f A - f a else setsum f A)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1044 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1045 |
prefer 2 apply (simp add: setsum_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1046 |
apply (erule finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1047 |
apply (auto simp add: insert_Diff_if) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1048 |
apply (drule_tac a = a in mk_disjoint_insert, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1049 |
done |
15402 | 1050 |
|
1051 |
lemma setsum_diff1: "finite A \<Longrightarrow> |
|
1052 |
(setsum f (A - {a}) :: ('a::ab_group_add)) = |
|
1053 |
(if a:A then setsum f A - f a else setsum f A)" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1054 |
by (erule finite_induct) (auto simp add: insert_Diff_if) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1055 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1056 |
lemma setsum_diff1'[rule_format]: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1057 |
"finite A \<Longrightarrow> a \<in> A \<longrightarrow> (\<Sum> x \<in> A. f x) = f a + (\<Sum> x \<in> (A - {a}). f x)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1058 |
apply (erule finite_induct[where F=A and P="% A. (a \<in> A \<longrightarrow> (\<Sum> x \<in> A. f x) = f a + (\<Sum> x \<in> (A - {a}). f x))"]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1059 |
apply (auto simp add: insert_Diff_if add_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1060 |
done |
15552
8ab8e425410b
added setsum_diff1' which holds in more general cases than setsum_diff1
obua
parents:
15543
diff
changeset
|
1061 |
|
15402 | 1062 |
(* By Jeremy Siek: *) |
1063 |
||
1064 |
lemma setsum_diff_nat: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1065 |
assumes "finite B" and "B \<subseteq> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1066 |
shows "(setsum f (A - B) :: nat) = (setsum f A) - (setsum f B)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1067 |
using assms |
19535 | 1068 |
proof induct |
15402 | 1069 |
show "setsum f (A - {}) = (setsum f A) - (setsum f {})" by simp |
1070 |
next |
|
1071 |
fix F x assume finF: "finite F" and xnotinF: "x \<notin> F" |
|
1072 |
and xFinA: "insert x F \<subseteq> A" |
|
1073 |
and IH: "F \<subseteq> A \<Longrightarrow> setsum f (A - F) = setsum f A - setsum f F" |
|
1074 |
from xnotinF xFinA have xinAF: "x \<in> (A - F)" by simp |
|
1075 |
from xinAF have A: "setsum f ((A - F) - {x}) = setsum f (A - F) - f x" |
|
1076 |
by (simp add: setsum_diff1_nat) |
|
1077 |
from xFinA have "F \<subseteq> A" by simp |
|
1078 |
with IH have "setsum f (A - F) = setsum f A - setsum f F" by simp |
|
1079 |
with A have B: "setsum f ((A - F) - {x}) = setsum f A - setsum f F - f x" |
|
1080 |
by simp |
|
1081 |
from xnotinF have "A - insert x F = (A - F) - {x}" by auto |
|
1082 |
with B have C: "setsum f (A - insert x F) = setsum f A - setsum f F - f x" |
|
1083 |
by simp |
|
1084 |
from finF xnotinF have "setsum f (insert x F) = setsum f F + f x" by simp |
|
1085 |
with C have "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" |
|
1086 |
by simp |
|
1087 |
thus "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" by simp |
|
1088 |
qed |
|
1089 |
||
1090 |
lemma setsum_diff: |
|
1091 |
assumes le: "finite A" "B \<subseteq> A" |
|
1092 |
shows "setsum f (A - B) = setsum f A - ((setsum f B)::('a::ab_group_add))" |
|
1093 |
proof - |
|
1094 |
from le have finiteB: "finite B" using finite_subset by auto |
|
1095 |
show ?thesis using finiteB le |
|
21575 | 1096 |
proof induct |
19535 | 1097 |
case empty |
1098 |
thus ?case by auto |
|
1099 |
next |
|
1100 |
case (insert x F) |
|
1101 |
thus ?case using le finiteB |
|
1102 |
by (simp add: Diff_insert[where a=x and B=F] setsum_diff1 insert_absorb) |
|
15402 | 1103 |
qed |
19535 | 1104 |
qed |
15402 | 1105 |
|
1106 |
lemma setsum_mono: |
|
1107 |
assumes le: "\<And>i. i\<in>K \<Longrightarrow> f (i::'a) \<le> ((g i)::('b::{comm_monoid_add, pordered_ab_semigroup_add}))" |
|
1108 |
shows "(\<Sum>i\<in>K. f i) \<le> (\<Sum>i\<in>K. g i)" |
|
1109 |
proof (cases "finite K") |
|
1110 |
case True |
|
1111 |
thus ?thesis using le |
|
19535 | 1112 |
proof induct |
15402 | 1113 |
case empty |
1114 |
thus ?case by simp |
|
1115 |
next |
|
1116 |
case insert |
|
19535 | 1117 |
thus ?case using add_mono by fastsimp |
15402 | 1118 |
qed |
1119 |
next |
|
1120 |
case False |
|
1121 |
thus ?thesis |
|
1122 |
by (simp add: setsum_def) |
|
1123 |
qed |
|
1124 |
||
15554 | 1125 |
lemma setsum_strict_mono: |
19535 | 1126 |
fixes f :: "'a \<Rightarrow> 'b::{pordered_cancel_ab_semigroup_add,comm_monoid_add}" |
1127 |
assumes "finite A" "A \<noteq> {}" |
|
1128 |
and "!!x. x:A \<Longrightarrow> f x < g x" |
|
1129 |
shows "setsum f A < setsum g A" |
|
1130 |
using prems |
|
15554 | 1131 |
proof (induct rule: finite_ne_induct) |
1132 |
case singleton thus ?case by simp |
|
1133 |
next |
|
1134 |
case insert thus ?case by (auto simp: add_strict_mono) |
|
1135 |
qed |
|
1136 |
||
15535 | 1137 |
lemma setsum_negf: |
19535 | 1138 |
"setsum (%x. - (f x)::'a::ab_group_add) A = - setsum f A" |
15535 | 1139 |
proof (cases "finite A") |
22262 | 1140 |
case True thus ?thesis by (induct set: finite) auto |
15535 | 1141 |
next |
1142 |
case False thus ?thesis by (simp add: setsum_def) |
|
1143 |
qed |
|
15402 | 1144 |
|
15535 | 1145 |
lemma setsum_subtractf: |
19535 | 1146 |
"setsum (%x. ((f x)::'a::ab_group_add) - g x) A = |
1147 |
setsum f A - setsum g A" |
|
15535 | 1148 |
proof (cases "finite A") |
1149 |
case True thus ?thesis by (simp add: diff_minus setsum_addf setsum_negf) |
|
1150 |
next |
|
1151 |
case False thus ?thesis by (simp add: setsum_def) |
|
1152 |
qed |
|
15402 | 1153 |
|
15535 | 1154 |
lemma setsum_nonneg: |
19535 | 1155 |
assumes nn: "\<forall>x\<in>A. (0::'a::{pordered_ab_semigroup_add,comm_monoid_add}) \<le> f x" |
1156 |
shows "0 \<le> setsum f A" |
|
15535 | 1157 |
proof (cases "finite A") |
1158 |
case True thus ?thesis using nn |
|
21575 | 1159 |
proof induct |
19535 | 1160 |
case empty then show ?case by simp |
1161 |
next |
|
1162 |
case (insert x F) |
|
1163 |
then have "0 + 0 \<le> f x + setsum f F" by (blast intro: add_mono) |
|
1164 |
with insert show ?case by simp |
|
1165 |
qed |
|
15535 | 1166 |
next |
1167 |
case False thus ?thesis by (simp add: setsum_def) |
|
1168 |
qed |
|
15402 | 1169 |
|
15535 | 1170 |
lemma setsum_nonpos: |
19535 | 1171 |
assumes np: "\<forall>x\<in>A. f x \<le> (0::'a::{pordered_ab_semigroup_add,comm_monoid_add})" |
1172 |
shows "setsum f A \<le> 0" |
|
15535 | 1173 |
proof (cases "finite A") |
1174 |
case True thus ?thesis using np |
|
21575 | 1175 |
proof induct |
19535 | 1176 |
case empty then show ?case by simp |
1177 |
next |
|
1178 |
case (insert x F) |
|
1179 |
then have "f x + setsum f F \<le> 0 + 0" by (blast intro: add_mono) |
|
1180 |
with insert show ?case by simp |
|
1181 |
qed |
|
15535 | 1182 |
next |
1183 |
case False thus ?thesis by (simp add: setsum_def) |
|
1184 |
qed |
|
15402 | 1185 |
|
15539 | 1186 |
lemma setsum_mono2: |
1187 |
fixes f :: "'a \<Rightarrow> 'b :: {pordered_ab_semigroup_add_imp_le,comm_monoid_add}" |
|
1188 |
assumes fin: "finite B" and sub: "A \<subseteq> B" and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b" |
|
1189 |
shows "setsum f A \<le> setsum f B" |
|
1190 |
proof - |
|
1191 |
have "setsum f A \<le> setsum f A + setsum f (B-A)" |
|
1192 |
by(simp add: add_increasing2[OF setsum_nonneg] nn Ball_def) |
|
1193 |
also have "\<dots> = setsum f (A \<union> (B-A))" using fin finite_subset[OF sub fin] |
|
1194 |
by (simp add:setsum_Un_disjoint del:Un_Diff_cancel) |
|
1195 |
also have "A \<union> (B-A) = B" using sub by blast |
|
1196 |
finally show ?thesis . |
|
1197 |
qed |
|
15542 | 1198 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1199 |
lemma setsum_mono3: "finite B ==> A <= B ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1200 |
ALL x: B - A. |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1201 |
0 <= ((f x)::'a::{comm_monoid_add,pordered_ab_semigroup_add}) ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1202 |
setsum f A <= setsum f B" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1203 |
apply (subgoal_tac "setsum f B = setsum f A + setsum f (B - A)") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1204 |
apply (erule ssubst) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1205 |
apply (subgoal_tac "setsum f A + 0 <= setsum f A + setsum f (B - A)") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1206 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1207 |
apply (rule add_left_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1208 |
apply (erule setsum_nonneg) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1209 |
apply (subst setsum_Un_disjoint [THEN sym]) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1210 |
apply (erule finite_subset, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1211 |
apply (rule finite_subset) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1212 |
prefer 2 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1213 |
apply assumption |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1214 |
apply auto |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1215 |
apply (rule setsum_cong) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1216 |
apply auto |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1217 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1218 |
|
19279 | 1219 |
lemma setsum_right_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1220 |
fixes f :: "'a => ('b::semiring_0)" |
15402 | 1221 |
shows "r * setsum f A = setsum (%n. r * f n) A" |
1222 |
proof (cases "finite A") |
|
1223 |
case True |
|
1224 |
thus ?thesis |
|
21575 | 1225 |
proof induct |
15402 | 1226 |
case empty thus ?case by simp |
1227 |
next |
|
1228 |
case (insert x A) thus ?case by (simp add: right_distrib) |
|
1229 |
qed |
|
1230 |
next |
|
1231 |
case False thus ?thesis by (simp add: setsum_def) |
|
1232 |
qed |
|
1233 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1234 |
lemma setsum_left_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1235 |
"setsum f A * (r::'a::semiring_0) = (\<Sum>n\<in>A. f n * r)" |
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1236 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1237 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1238 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1239 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1240 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1241 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1242 |
case (insert x A) thus ?case by (simp add: left_distrib) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1243 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1244 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1245 |
case False thus ?thesis by (simp add: setsum_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1246 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1247 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1248 |
lemma setsum_divide_distrib: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1249 |
"setsum f A / (r::'a::field) = (\<Sum>n\<in>A. f n / r)" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1250 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1251 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1252 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1253 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1254 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1255 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1256 |
case (insert x A) thus ?case by (simp add: add_divide_distrib) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1257 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1258 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1259 |
case False thus ?thesis by (simp add: setsum_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1260 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1261 |
|
15535 | 1262 |
lemma setsum_abs[iff]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1263 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15402 | 1264 |
shows "abs (setsum f A) \<le> setsum (%i. abs(f i)) A" |
15535 | 1265 |
proof (cases "finite A") |
1266 |
case True |
|
1267 |
thus ?thesis |
|
21575 | 1268 |
proof induct |
15535 | 1269 |
case empty thus ?case by simp |
1270 |
next |
|
1271 |
case (insert x A) |
|
1272 |
thus ?case by (auto intro: abs_triangle_ineq order_trans) |
|
1273 |
qed |
|
15402 | 1274 |
next |
15535 | 1275 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 1276 |
qed |
1277 |
||
15535 | 1278 |
lemma setsum_abs_ge_zero[iff]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1279 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15402 | 1280 |
shows "0 \<le> setsum (%i. abs(f i)) A" |
15535 | 1281 |
proof (cases "finite A") |
1282 |
case True |
|
1283 |
thus ?thesis |
|
21575 | 1284 |
proof induct |
15535 | 1285 |
case empty thus ?case by simp |
1286 |
next |
|
21733 | 1287 |
case (insert x A) thus ?case by (auto simp: add_nonneg_nonneg) |
15535 | 1288 |
qed |
15402 | 1289 |
next |
15535 | 1290 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 1291 |
qed |
1292 |
||
15539 | 1293 |
lemma abs_setsum_abs[simp]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1294 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15539 | 1295 |
shows "abs (\<Sum>a\<in>A. abs(f a)) = (\<Sum>a\<in>A. abs(f a))" |
1296 |
proof (cases "finite A") |
|
1297 |
case True |
|
1298 |
thus ?thesis |
|
21575 | 1299 |
proof induct |
15539 | 1300 |
case empty thus ?case by simp |
1301 |
next |
|
1302 |
case (insert a A) |
|
1303 |
hence "\<bar>\<Sum>a\<in>insert a A. \<bar>f a\<bar>\<bar> = \<bar>\<bar>f a\<bar> + (\<Sum>a\<in>A. \<bar>f a\<bar>)\<bar>" by simp |
|
1304 |
also have "\<dots> = \<bar>\<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>\<bar>" using insert by simp |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1305 |
also have "\<dots> = \<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1306 |
by (simp del: abs_of_nonneg) |
15539 | 1307 |
also have "\<dots> = (\<Sum>a\<in>insert a A. \<bar>f a\<bar>)" using insert by simp |
1308 |
finally show ?case . |
|
1309 |
qed |
|
1310 |
next |
|
1311 |
case False thus ?thesis by (simp add: setsum_def) |
|
1312 |
qed |
|
1313 |
||
15402 | 1314 |
|
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1315 |
text {* Commuting outer and inner summation *} |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1316 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1317 |
lemma swap_inj_on: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1318 |
"inj_on (%(i, j). (j, i)) (A \<times> B)" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1319 |
by (unfold inj_on_def) fast |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1320 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1321 |
lemma swap_product: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1322 |
"(%(i, j). (j, i)) ` (A \<times> B) = B \<times> A" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1323 |
by (simp add: split_def image_def) blast |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1324 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1325 |
lemma setsum_commute: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1326 |
"(\<Sum>i\<in>A. \<Sum>j\<in>B. f i j) = (\<Sum>j\<in>B. \<Sum>i\<in>A. f i j)" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1327 |
proof (simp add: setsum_cartesian_product) |
17189 | 1328 |
have "(\<Sum>(x,y) \<in> A <*> B. f x y) = |
1329 |
(\<Sum>(y,x) \<in> (%(i, j). (j, i)) ` (A \<times> B). f x y)" |
|
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1330 |
(is "?s = _") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1331 |
apply (simp add: setsum_reindex [where f = "%(i, j). (j, i)"] swap_inj_on) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1332 |
apply (simp add: split_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1333 |
done |
17189 | 1334 |
also have "... = (\<Sum>(y,x)\<in>B \<times> A. f x y)" |
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1335 |
(is "_ = ?t") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1336 |
apply (simp add: swap_product) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1337 |
done |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1338 |
finally show "?s = ?t" . |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1339 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1340 |
|
19279 | 1341 |
lemma setsum_product: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1342 |
fixes f :: "'a => ('b::semiring_0)" |
19279 | 1343 |
shows "setsum f A * setsum g B = (\<Sum>i\<in>A. \<Sum>j\<in>B. f i * g j)" |
1344 |
by (simp add: setsum_right_distrib setsum_left_distrib) (rule setsum_commute) |
|
1345 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1346 |
|
15402 | 1347 |
subsection {* Generalized product over a set *} |
1348 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1349 |
definition setprod :: "('a => 'b) => 'a set => 'b::comm_monoid_mult" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1350 |
where "setprod f A == if finite A then fold_image (op *) f 1 A else 1" |
15402 | 1351 |
|
19535 | 1352 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
1353 |
Setprod ("\<Prod>_" [1000] 999) where |
19535 | 1354 |
"\<Prod>A == setprod (%x. x) A" |
1355 |
||
15402 | 1356 |
syntax |
17189 | 1357 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3PROD _:_. _)" [0, 51, 10] 10) |
15402 | 1358 |
syntax (xsymbols) |
17189 | 1359 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 1360 |
syntax (HTML output) |
17189 | 1361 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
16550 | 1362 |
|
1363 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1364 |
"PROD i:A. b" == "CONST setprod (%i. b) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1365 |
"\<Prod>i\<in>A. b" == "CONST setprod (%i. b) A" |
16550 | 1366 |
|
1367 |
text{* Instead of @{term"\<Prod>x\<in>{x. P}. e"} we introduce the shorter |
|
1368 |
@{text"\<Prod>x|P. e"}. *} |
|
1369 |
||
1370 |
syntax |
|
17189 | 1371 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3PROD _ |/ _./ _)" [0,0,10] 10) |
16550 | 1372 |
syntax (xsymbols) |
17189 | 1373 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 1374 |
syntax (HTML output) |
17189 | 1375 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 1376 |
|
15402 | 1377 |
translations |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1378 |
"PROD x|P. t" => "CONST setprod (%x. t) {x. P}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1379 |
"\<Prod>x|P. t" => "CONST setprod (%x. t) {x. P}" |
16550 | 1380 |
|
15402 | 1381 |
|
1382 |
lemma setprod_empty [simp]: "setprod f {} = 1" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1383 |
by (auto simp add: setprod_def) |
15402 | 1384 |
|
1385 |
lemma setprod_insert [simp]: "[| finite A; a \<notin> A |] ==> |
|
1386 |
setprod f (insert a A) = f a * setprod f A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1387 |
by (simp add: setprod_def) |
15402 | 1388 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1389 |
lemma setprod_infinite [simp]: "~ finite A ==> setprod f A = 1" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1390 |
by (simp add: setprod_def) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1391 |
|
15402 | 1392 |
lemma setprod_reindex: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1393 |
"inj_on f B ==> setprod h (f ` B) = setprod (h \<circ> f) B" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1394 |
by(auto simp: setprod_def fold_image_reindex dest!:finite_imageD) |
15402 | 1395 |
|
1396 |
lemma setprod_reindex_id: "inj_on f B ==> setprod f B = setprod id (f ` B)" |
|
1397 |
by (auto simp add: setprod_reindex) |
|
1398 |
||
1399 |
lemma setprod_cong: |
|
1400 |
"A = B ==> (!!x. x:B ==> f x = g x) ==> setprod f A = setprod g B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1401 |
by(fastsimp simp: setprod_def intro: fold_image_cong) |
15402 | 1402 |
|
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
1403 |
lemma strong_setprod_cong: |
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
1404 |
"A = B ==> (!!x. x:B =simp=> f x = g x) ==> setprod f A = setprod g B" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1405 |
by(fastsimp simp: simp_implies_def setprod_def intro: fold_image_cong) |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
1406 |
|
15402 | 1407 |
lemma setprod_reindex_cong: "inj_on f A ==> |
1408 |
B = f ` A ==> g = h \<circ> f ==> setprod h B = setprod g A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1409 |
by (frule setprod_reindex, simp) |
15402 | 1410 |
|
1411 |
||
1412 |
lemma setprod_1: "setprod (%i. 1) A = 1" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1413 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1414 |
apply (erule finite_induct, auto simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1415 |
done |
15402 | 1416 |
|
1417 |
lemma setprod_1': "ALL a:F. f a = 1 ==> setprod f F = 1" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1418 |
apply (subgoal_tac "setprod f F = setprod (%x. 1) F") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1419 |
apply (erule ssubst, rule setprod_1) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1420 |
apply (rule setprod_cong, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1421 |
done |
15402 | 1422 |
|
1423 |
lemma setprod_Un_Int: "finite A ==> finite B |
|
1424 |
==> setprod g (A Un B) * setprod g (A Int B) = setprod g A * setprod g B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1425 |
by(simp add: setprod_def fold_image_Un_Int[symmetric]) |
15402 | 1426 |
|
1427 |
lemma setprod_Un_disjoint: "finite A ==> finite B |
|
1428 |
==> A Int B = {} ==> setprod g (A Un B) = setprod g A * setprod g B" |
|
1429 |
by (subst setprod_Un_Int [symmetric], auto) |
|
1430 |
||
1431 |
lemma setprod_UN_disjoint: |
|
1432 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
|
1433 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==> |
|
1434 |
setprod f (UNION I A) = setprod (%i. setprod f (A i)) I" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1435 |
by(simp add: setprod_def fold_image_UN_disjoint cong: setprod_cong) |
15402 | 1436 |
|
1437 |
lemma setprod_Union_disjoint: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1438 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1439 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |] |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1440 |
==> setprod f (Union C) = setprod (setprod f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1441 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1442 |
prefer 2 apply (force dest: finite_UnionD simp add: setprod_def) |
15402 | 1443 |
apply (frule setprod_UN_disjoint [of C id f]) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1444 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1445 |
done |
15402 | 1446 |
|
1447 |
lemma setprod_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
|
16550 | 1448 |
(\<Prod>x\<in>A. (\<Prod>y\<in> B x. f x y)) = |
17189 | 1449 |
(\<Prod>(x,y)\<in>(SIGMA x:A. B x). f x y)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1450 |
by(simp add:setprod_def fold_image_Sigma split_def cong:setprod_cong) |
15402 | 1451 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1452 |
text{*Here we can eliminate the finiteness assumptions, by cases.*} |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1453 |
lemma setprod_cartesian_product: |
17189 | 1454 |
"(\<Prod>x\<in>A. (\<Prod>y\<in> B. f x y)) = (\<Prod>(x,y)\<in>(A <*> B). f x y)" |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1455 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1456 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1457 |
apply (simp add: setprod_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1458 |
apply (cases "A={}", simp) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1459 |
apply (simp add: setprod_1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1460 |
apply (auto simp add: setprod_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1461 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1462 |
done |
15402 | 1463 |
|
1464 |
lemma setprod_timesf: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1465 |
"setprod (%x. f x * g x) A = (setprod f A * setprod g A)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1466 |
by(simp add:setprod_def fold_image_distrib) |
15402 | 1467 |
|
1468 |
||
1469 |
subsubsection {* Properties in more restricted classes of structures *} |
|
1470 |
||
1471 |
lemma setprod_eq_1_iff [simp]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1472 |
"finite F ==> (setprod f F = 1) = (ALL a:F. f a = (1::nat))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1473 |
by (induct set: finite) auto |
15402 | 1474 |
|
1475 |
lemma setprod_zero: |
|
23277 | 1476 |
"finite A ==> EX x: A. f x = (0::'a::comm_semiring_1) ==> setprod f A = 0" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1477 |
apply (induct set: finite, force, clarsimp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1478 |
apply (erule disjE, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1479 |
done |
15402 | 1480 |
|
1481 |
lemma setprod_nonneg [rule_format]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1482 |
"(ALL x: A. (0::'a::ordered_idom) \<le> f x) --> 0 \<le> setprod f A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1483 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1484 |
apply (induct set: finite, force, clarsimp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1485 |
apply (subgoal_tac "0 * 0 \<le> f x * setprod f F", force) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1486 |
apply (rule mult_mono, assumption+) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1487 |
apply (auto simp add: setprod_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1488 |
done |
15402 | 1489 |
|
1490 |
lemma setprod_pos [rule_format]: "(ALL x: A. (0::'a::ordered_idom) < f x) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1491 |
--> 0 < setprod f A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1492 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1493 |
apply (induct set: finite, force, clarsimp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1494 |
apply (subgoal_tac "0 * 0 < f x * setprod f F", force) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1495 |
apply (rule mult_strict_mono, assumption+) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1496 |
apply (auto simp add: setprod_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1497 |
done |
15402 | 1498 |
|
1499 |
lemma setprod_nonzero [rule_format]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1500 |
"(ALL x y. (x::'a::comm_semiring_1) * y = 0 --> x = 0 | y = 0) ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1501 |
finite A ==> (ALL x: A. f x \<noteq> (0::'a)) --> setprod f A \<noteq> 0" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1502 |
by (erule finite_induct, auto) |
15402 | 1503 |
|
1504 |
lemma setprod_zero_eq: |
|
23277 | 1505 |
"(ALL x y. (x::'a::comm_semiring_1) * y = 0 --> x = 0 | y = 0) ==> |
15402 | 1506 |
finite A ==> (setprod f A = (0::'a)) = (EX x: A. f x = 0)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1507 |
by (insert setprod_zero [of A f] setprod_nonzero [of A f], blast) |
15402 | 1508 |
|
1509 |
lemma setprod_nonzero_field: |
|
23277 | 1510 |
"finite A ==> (ALL x: A. f x \<noteq> (0::'a::idom)) ==> setprod f A \<noteq> 0" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1511 |
by (rule setprod_nonzero, auto) |
15402 | 1512 |
|
1513 |
lemma setprod_zero_eq_field: |
|
23277 | 1514 |
"finite A ==> (setprod f A = (0::'a::idom)) = (EX x: A. f x = 0)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1515 |
by (rule setprod_zero_eq, auto) |
15402 | 1516 |
|
1517 |
lemma setprod_Un: "finite A ==> finite B ==> (ALL x: A Int B. f x \<noteq> 0) ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1518 |
(setprod f (A Un B) :: 'a ::{field}) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1519 |
= setprod f A * setprod f B / setprod f (A Int B)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1520 |
apply (subst setprod_Un_Int [symmetric], auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1521 |
apply (subgoal_tac "finite (A Int B)") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1522 |
apply (frule setprod_nonzero_field [of "A Int B" f], assumption) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1523 |
apply (subst times_divide_eq_right [THEN sym], auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1524 |
done |
15402 | 1525 |
|
1526 |
lemma setprod_diff1: "finite A ==> f a \<noteq> 0 ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1527 |
(setprod f (A - {a}) :: 'a :: {field}) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1528 |
(if a:A then setprod f A / f a else setprod f A)" |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23398
diff
changeset
|
1529 |
by (erule finite_induct) (auto simp add: insert_Diff_if) |
15402 | 1530 |
|
1531 |
lemma setprod_inversef: "finite A ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1532 |
ALL x: A. f x \<noteq> (0::'a::{field,division_by_zero}) ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1533 |
setprod (inverse \<circ> f) A = inverse (setprod f A)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1534 |
by (erule finite_induct) auto |
15402 | 1535 |
|
1536 |
lemma setprod_dividef: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1537 |
"[|finite A; |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1538 |
\<forall>x \<in> A. g x \<noteq> (0::'a::{field,division_by_zero})|] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1539 |
==> setprod (%x. f x / g x) A = setprod f A / setprod g A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1540 |
apply (subgoal_tac |
15402 | 1541 |
"setprod (%x. f x / g x) A = setprod (%x. f x * (inverse \<circ> g) x) A") |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1542 |
apply (erule ssubst) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1543 |
apply (subst divide_inverse) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1544 |
apply (subst setprod_timesf) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1545 |
apply (subst setprod_inversef, assumption+, rule refl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1546 |
apply (rule setprod_cong, rule refl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1547 |
apply (subst divide_inverse, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1548 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1549 |
|
15402 | 1550 |
|
12396 | 1551 |
subsection {* Finite cardinality *} |
1552 |
||
15402 | 1553 |
text {* This definition, although traditional, is ugly to work with: |
1554 |
@{text "card A == LEAST n. EX f. A = {f i | i. i < n}"}. |
|
1555 |
But now that we have @{text setsum} things are easy: |
|
12396 | 1556 |
*} |
1557 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1558 |
definition card :: "'a set \<Rightarrow> nat" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1559 |
where "card A = setsum (\<lambda>x. 1) A" |
12396 | 1560 |
|
1561 |
lemma card_empty [simp]: "card {} = 0" |
|
24853 | 1562 |
by (simp add: card_def) |
15402 | 1563 |
|
24427 | 1564 |
lemma card_infinite [simp]: "~ finite A ==> card A = 0" |
24853 | 1565 |
by (simp add: card_def) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1566 |
|
15402 | 1567 |
lemma card_eq_setsum: "card A = setsum (%x. 1) A" |
1568 |
by (simp add: card_def) |
|
12396 | 1569 |
|
1570 |
lemma card_insert_disjoint [simp]: |
|
1571 |
"finite A ==> x \<notin> A ==> card (insert x A) = Suc(card A)" |
|
15765 | 1572 |
by(simp add: card_def) |
15402 | 1573 |
|
1574 |
lemma card_insert_if: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1575 |
"finite A ==> card (insert x A) = (if x:A then card A else Suc(card(A)))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1576 |
by (simp add: insert_absorb) |
12396 | 1577 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
1578 |
lemma card_0_eq [simp,noatp]: "finite A ==> (card A = 0) = (A = {})" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1579 |
apply auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1580 |
apply (drule_tac a = x in mk_disjoint_insert, clarify, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1581 |
done |
12396 | 1582 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1583 |
lemma card_eq_0_iff: "(card A = 0) = (A = {} | ~ finite A)" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1584 |
by auto |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1585 |
|
24853 | 1586 |
|
12396 | 1587 |
lemma card_Suc_Diff1: "finite A ==> x: A ==> Suc (card (A - {x})) = card A" |
14302 | 1588 |
apply(rule_tac t = A in insert_Diff [THEN subst], assumption) |
1589 |
apply(simp del:insert_Diff_single) |
|
1590 |
done |
|
12396 | 1591 |
|
1592 |
lemma card_Diff_singleton: |
|
24853 | 1593 |
"finite A ==> x: A ==> card (A - {x}) = card A - 1" |
1594 |
by (simp add: card_Suc_Diff1 [symmetric]) |
|
12396 | 1595 |
|
1596 |
lemma card_Diff_singleton_if: |
|
24853 | 1597 |
"finite A ==> card (A-{x}) = (if x : A then card A - 1 else card A)" |
1598 |
by (simp add: card_Diff_singleton) |
|
1599 |
||
1600 |
lemma card_Diff_insert[simp]: |
|
1601 |
assumes "finite A" and "a:A" and "a ~: B" |
|
1602 |
shows "card(A - insert a B) = card(A - B) - 1" |
|
1603 |
proof - |
|
1604 |
have "A - insert a B = (A - B) - {a}" using assms by blast |
|
1605 |
then show ?thesis using assms by(simp add:card_Diff_singleton) |
|
1606 |
qed |
|
12396 | 1607 |
|
1608 |
lemma card_insert: "finite A ==> card (insert x A) = Suc (card (A - {x}))" |
|
24853 | 1609 |
by (simp add: card_insert_if card_Suc_Diff1 del:card_Diff_insert) |
12396 | 1610 |
|
1611 |
lemma card_insert_le: "finite A ==> card A <= card (insert x A)" |
|
24853 | 1612 |
by (simp add: card_insert_if) |
12396 | 1613 |
|
15402 | 1614 |
lemma card_mono: "\<lbrakk> finite B; A \<subseteq> B \<rbrakk> \<Longrightarrow> card A \<le> card B" |
15539 | 1615 |
by (simp add: card_def setsum_mono2) |
15402 | 1616 |
|
12396 | 1617 |
lemma card_seteq: "finite B ==> (!!A. A <= B ==> card B <= card A ==> A = B)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1618 |
apply (induct set: finite, simp, clarify) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1619 |
apply (subgoal_tac "finite A & A - {x} <= F") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1620 |
prefer 2 apply (blast intro: finite_subset, atomize) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1621 |
apply (drule_tac x = "A - {x}" in spec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1622 |
apply (simp add: card_Diff_singleton_if split add: split_if_asm) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1623 |
apply (case_tac "card A", auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1624 |
done |
12396 | 1625 |
|
1626 |
lemma psubset_card_mono: "finite B ==> A < B ==> card A < card B" |
|
26792 | 1627 |
apply (simp add: psubset_eq linorder_not_le [symmetric]) |
24853 | 1628 |
apply (blast dest: card_seteq) |
1629 |
done |
|
12396 | 1630 |
|
1631 |
lemma card_Un_Int: "finite A ==> finite B |
|
1632 |
==> card A + card B = card (A Un B) + card (A Int B)" |
|
15402 | 1633 |
by(simp add:card_def setsum_Un_Int) |
12396 | 1634 |
|
1635 |
lemma card_Un_disjoint: "finite A ==> finite B |
|
1636 |
==> A Int B = {} ==> card (A Un B) = card A + card B" |
|
24853 | 1637 |
by (simp add: card_Un_Int) |
12396 | 1638 |
|
1639 |
lemma card_Diff_subset: |
|
15402 | 1640 |
"finite B ==> B <= A ==> card (A - B) = card A - card B" |
1641 |
by(simp add:card_def setsum_diff_nat) |
|
12396 | 1642 |
|
1643 |
lemma card_Diff1_less: "finite A ==> x: A ==> card (A - {x}) < card A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1644 |
apply (rule Suc_less_SucD) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1645 |
apply (simp add: card_Suc_Diff1 del:card_Diff_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1646 |
done |
12396 | 1647 |
|
1648 |
lemma card_Diff2_less: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1649 |
"finite A ==> x: A ==> y: A ==> card (A - {x} - {y}) < card A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1650 |
apply (case_tac "x = y") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1651 |
apply (simp add: card_Diff1_less del:card_Diff_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1652 |
apply (rule less_trans) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1653 |
prefer 2 apply (auto intro!: card_Diff1_less simp del:card_Diff_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1654 |
done |
12396 | 1655 |
|
1656 |
lemma card_Diff1_le: "finite A ==> card (A - {x}) <= card A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1657 |
apply (case_tac "x : A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1658 |
apply (simp_all add: card_Diff1_less less_imp_le) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1659 |
done |
12396 | 1660 |
|
1661 |
lemma card_psubset: "finite B ==> A \<subseteq> B ==> card A < card B ==> A < B" |
|
14208 | 1662 |
by (erule psubsetI, blast) |
12396 | 1663 |
|
14889 | 1664 |
lemma insert_partition: |
15402 | 1665 |
"\<lbrakk> x \<notin> F; \<forall>c1 \<in> insert x F. \<forall>c2 \<in> insert x F. c1 \<noteq> c2 \<longrightarrow> c1 \<inter> c2 = {} \<rbrakk> |
1666 |
\<Longrightarrow> x \<inter> \<Union> F = {}" |
|
14889 | 1667 |
by auto |
1668 |
||
19793 | 1669 |
text{* main cardinality theorem *} |
14889 | 1670 |
lemma card_partition [rule_format]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1671 |
"finite C ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1672 |
finite (\<Union> C) --> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1673 |
(\<forall>c\<in>C. card c = k) --> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1674 |
(\<forall>c1 \<in> C. \<forall>c2 \<in> C. c1 \<noteq> c2 --> c1 \<inter> c2 = {}) --> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1675 |
k * card(C) = card (\<Union> C)" |
14889 | 1676 |
apply (erule finite_induct, simp) |
1677 |
apply (simp add: card_insert_disjoint card_Un_disjoint insert_partition |
|
1678 |
finite_subset [of _ "\<Union> (insert x F)"]) |
|
1679 |
done |
|
1680 |
||
12396 | 1681 |
|
19793 | 1682 |
text{*The form of a finite set of given cardinality*} |
1683 |
||
1684 |
lemma card_eq_SucD: |
|
24853 | 1685 |
assumes "card A = Suc k" |
1686 |
shows "\<exists>b B. A = insert b B & b \<notin> B & card B = k & (k=0 \<longrightarrow> B={})" |
|
19793 | 1687 |
proof - |
24853 | 1688 |
have fin: "finite A" using assms by (auto intro: ccontr) |
1689 |
moreover have "card A \<noteq> 0" using assms by auto |
|
1690 |
ultimately obtain b where b: "b \<in> A" by auto |
|
19793 | 1691 |
show ?thesis |
1692 |
proof (intro exI conjI) |
|
1693 |
show "A = insert b (A-{b})" using b by blast |
|
1694 |
show "b \<notin> A - {b}" by blast |
|
24853 | 1695 |
show "card (A - {b}) = k" and "k = 0 \<longrightarrow> A - {b} = {}" |
1696 |
using assms b fin by(fastsimp dest:mk_disjoint_insert)+ |
|
19793 | 1697 |
qed |
1698 |
qed |
|
1699 |
||
1700 |
lemma card_Suc_eq: |
|
24853 | 1701 |
"(card A = Suc k) = |
1702 |
(\<exists>b B. A = insert b B & b \<notin> B & card B = k & (k=0 \<longrightarrow> B={}))" |
|
1703 |
apply(rule iffI) |
|
1704 |
apply(erule card_eq_SucD) |
|
1705 |
apply(auto) |
|
1706 |
apply(subst card_insert) |
|
1707 |
apply(auto intro:ccontr) |
|
1708 |
done |
|
19793 | 1709 |
|
15539 | 1710 |
lemma setsum_constant [simp]: "(\<Sum>x \<in> A. y) = of_nat(card A) * y" |
1711 |
apply (cases "finite A") |
|
1712 |
apply (erule finite_induct) |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1713 |
apply (auto simp add: ring_simps) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1714 |
done |
15402 | 1715 |
|
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
19984
diff
changeset
|
1716 |
lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::{recpower, comm_monoid_mult})) = y^(card A)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1717 |
apply (erule finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1718 |
apply (auto simp add: power_Suc) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1719 |
done |
15402 | 1720 |
|
15542 | 1721 |
lemma setsum_bounded: |
23277 | 1722 |
assumes le: "\<And>i. i\<in>A \<Longrightarrow> f i \<le> (K::'a::{semiring_1, pordered_ab_semigroup_add})" |
15542 | 1723 |
shows "setsum f A \<le> of_nat(card A) * K" |
1724 |
proof (cases "finite A") |
|
1725 |
case True |
|
1726 |
thus ?thesis using le setsum_mono[where K=A and g = "%x. K"] by simp |
|
1727 |
next |
|
1728 |
case False thus ?thesis by (simp add: setsum_def) |
|
1729 |
qed |
|
1730 |
||
15402 | 1731 |
|
1732 |
subsubsection {* Cardinality of unions *} |
|
1733 |
||
1734 |
lemma card_UN_disjoint: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1735 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1736 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1737 |
==> card (UNION I A) = (\<Sum>i\<in>I. card(A i))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1738 |
apply (simp add: card_def del: setsum_constant) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1739 |
apply (subgoal_tac |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1740 |
"setsum (%i. card (A i)) I = setsum (%i. (setsum (%x. 1) (A i))) I") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1741 |
apply (simp add: setsum_UN_disjoint del: setsum_constant) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1742 |
apply (simp cong: setsum_cong) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1743 |
done |
15402 | 1744 |
|
1745 |
lemma card_Union_disjoint: |
|
1746 |
"finite C ==> (ALL A:C. finite A) ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1747 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1748 |
==> card (Union C) = setsum card C" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1749 |
apply (frule card_UN_disjoint [of C id]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1750 |
apply (unfold Union_def id_def, assumption+) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1751 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1752 |
|
15402 | 1753 |
|
12396 | 1754 |
subsubsection {* Cardinality of image *} |
1755 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1756 |
text{*The image of a finite set can be expressed using @{term fold_image}.*} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1757 |
lemma image_eq_fold_image: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1758 |
"finite A ==> f ` A = fold_image (op Un) (%x. {f x}) {} A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1759 |
proof (induct rule: finite_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1760 |
case empty then show ?case by simp |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1761 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1762 |
interpret ab_semigroup_mult "op Un" |
28823 | 1763 |
proof qed auto |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1764 |
case insert |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1765 |
then show ?case by simp |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1766 |
qed |
15447 | 1767 |
|
12396 | 1768 |
lemma card_image_le: "finite A ==> card (f ` A) <= card A" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1769 |
apply (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1770 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1771 |
apply (simp add: le_SucI finite_imageI card_insert_if) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1772 |
done |
12396 | 1773 |
|
15402 | 1774 |
lemma card_image: "inj_on f A ==> card (f ` A) = card A" |
15539 | 1775 |
by(simp add:card_def setsum_reindex o_def del:setsum_constant) |
12396 | 1776 |
|
1777 |
lemma endo_inj_surj: "finite A ==> f ` A \<subseteq> A ==> inj_on f A ==> f ` A = A" |
|
25162 | 1778 |
by (simp add: card_seteq card_image) |
12396 | 1779 |
|
15111 | 1780 |
lemma eq_card_imp_inj_on: |
1781 |
"[| finite A; card(f ` A) = card A |] ==> inj_on f A" |
|
21575 | 1782 |
apply (induct rule:finite_induct) |
1783 |
apply simp |
|
15111 | 1784 |
apply(frule card_image_le[where f = f]) |
1785 |
apply(simp add:card_insert_if split:if_splits) |
|
1786 |
done |
|
1787 |
||
1788 |
lemma inj_on_iff_eq_card: |
|
1789 |
"finite A ==> inj_on f A = (card(f ` A) = card A)" |
|
1790 |
by(blast intro: card_image eq_card_imp_inj_on) |
|
1791 |
||
12396 | 1792 |
|
15402 | 1793 |
lemma card_inj_on_le: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1794 |
"[|inj_on f A; f ` A \<subseteq> B; finite B |] ==> card A \<le> card B" |
15402 | 1795 |
apply (subgoal_tac "finite A") |
1796 |
apply (force intro: card_mono simp add: card_image [symmetric]) |
|
1797 |
apply (blast intro: finite_imageD dest: finite_subset) |
|
1798 |
done |
|
1799 |
||
1800 |
lemma card_bij_eq: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1801 |
"[|inj_on f A; f ` A \<subseteq> B; inj_on g B; g ` B \<subseteq> A; |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1802 |
finite A; finite B |] ==> card A = card B" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1803 |
by (auto intro: le_anti_sym card_inj_on_le) |
15402 | 1804 |
|
1805 |
||
1806 |
subsubsection {* Cardinality of products *} |
|
1807 |
||
1808 |
(* |
|
1809 |
lemma SigmaI_insert: "y \<notin> A ==> |
|
1810 |
(SIGMA x:(insert y A). B x) = (({y} <*> (B y)) \<union> (SIGMA x: A. B x))" |
|
1811 |
by auto |
|
1812 |
*) |
|
1813 |
||
1814 |
lemma card_SigmaI [simp]: |
|
1815 |
"\<lbrakk> finite A; ALL a:A. finite (B a) \<rbrakk> |
|
1816 |
\<Longrightarrow> card (SIGMA x: A. B x) = (\<Sum>a\<in>A. card (B a))" |
|
15539 | 1817 |
by(simp add:card_def setsum_Sigma del:setsum_constant) |
15402 | 1818 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1819 |
lemma card_cartesian_product: "card (A <*> B) = card(A) * card(B)" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1820 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1821 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1822 |
apply (auto simp add: card_eq_0_iff |
15539 | 1823 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1824 |
done |
15402 | 1825 |
|
1826 |
lemma card_cartesian_product_singleton: "card({x} <*> A) = card(A)" |
|
15539 | 1827 |
by (simp add: card_cartesian_product) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1828 |
|
15402 | 1829 |
|
29025
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1830 |
subsubsection {* Cardinality of sums *} |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1831 |
|
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1832 |
lemma card_Plus: |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1833 |
assumes "finite A" and "finite B" |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1834 |
shows "card (A <+> B) = card A + card B" |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1835 |
proof - |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1836 |
have "Inl`A \<inter> Inr`B = {}" by fast |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1837 |
with assms show ?thesis |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1838 |
unfolding Plus_def |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1839 |
by (simp add: card_Un_disjoint card_image) |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1840 |
qed |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
1841 |
|
15402 | 1842 |
|
12396 | 1843 |
subsubsection {* Cardinality of the Powerset *} |
1844 |
||
1845 |
lemma card_Pow: "finite A ==> card (Pow A) = Suc (Suc 0) ^ card A" (* FIXME numeral 2 (!?) *) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1846 |
apply (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1847 |
apply (simp_all add: Pow_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1848 |
apply (subst card_Un_disjoint, blast) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1849 |
apply (blast intro: finite_imageI, blast) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1850 |
apply (subgoal_tac "inj_on (insert x) (Pow F)") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1851 |
apply (simp add: card_image Pow_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1852 |
apply (unfold inj_on_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1853 |
apply (blast elim!: equalityE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1854 |
done |
12396 | 1855 |
|
24342 | 1856 |
text {* Relates to equivalence classes. Based on a theorem of F. Kammüller. *} |
12396 | 1857 |
|
1858 |
lemma dvd_partition: |
|
15392 | 1859 |
"finite (Union C) ==> |
12396 | 1860 |
ALL c : C. k dvd card c ==> |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
1861 |
(ALL c1: C. ALL c2: C. c1 \<noteq> c2 --> c1 Int c2 = {}) ==> |
12396 | 1862 |
k dvd card (Union C)" |
15392 | 1863 |
apply(frule finite_UnionD) |
1864 |
apply(rotate_tac -1) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1865 |
apply (induct set: finite, simp_all, clarify) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1866 |
apply (subst card_Un_disjoint) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1867 |
apply (auto simp add: dvd_add disjoint_eq_subset_Compl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1868 |
done |
12396 | 1869 |
|
1870 |
||
25162 | 1871 |
subsubsection {* Relating injectivity and surjectivity *} |
1872 |
||
1873 |
lemma finite_surj_inj: "finite(A) \<Longrightarrow> A <= f`A \<Longrightarrow> inj_on f A" |
|
1874 |
apply(rule eq_card_imp_inj_on, assumption) |
|
1875 |
apply(frule finite_imageI) |
|
1876 |
apply(drule (1) card_seteq) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1877 |
apply(erule card_image_le) |
25162 | 1878 |
apply simp |
1879 |
done |
|
1880 |
||
1881 |
lemma finite_UNIV_surj_inj: fixes f :: "'a \<Rightarrow> 'a" |
|
1882 |
shows "finite(UNIV:: 'a set) \<Longrightarrow> surj f \<Longrightarrow> inj f" |
|
1883 |
by (blast intro: finite_surj_inj subset_UNIV dest:surj_range) |
|
1884 |
||
1885 |
lemma finite_UNIV_inj_surj: fixes f :: "'a \<Rightarrow> 'a" |
|
1886 |
shows "finite(UNIV:: 'a set) \<Longrightarrow> inj f \<Longrightarrow> surj f" |
|
1887 |
by(fastsimp simp:surj_def dest!: endo_inj_surj) |
|
1888 |
||
1889 |
corollary infinite_UNIV_nat: "~finite(UNIV::nat set)" |
|
1890 |
proof |
|
1891 |
assume "finite(UNIV::nat set)" |
|
1892 |
with finite_UNIV_inj_surj[of Suc] |
|
1893 |
show False by simp (blast dest: Suc_neq_Zero surjD) |
|
1894 |
qed |
|
1895 |
||
1896 |
||
15392 | 1897 |
subsection{* A fold functional for non-empty sets *} |
1898 |
||
1899 |
text{* Does not require start value. *} |
|
12396 | 1900 |
|
23736 | 1901 |
inductive |
22262 | 1902 |
fold1Set :: "('a => 'a => 'a) => 'a set => 'a => bool" |
1903 |
for f :: "'a => 'a => 'a" |
|
1904 |
where |
|
15506 | 1905 |
fold1Set_insertI [intro]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1906 |
"\<lbrakk> fold_graph f a A x; a \<notin> A \<rbrakk> \<Longrightarrow> fold1Set f (insert a A) x" |
12396 | 1907 |
|
15392 | 1908 |
constdefs |
1909 |
fold1 :: "('a => 'a => 'a) => 'a set => 'a" |
|
22262 | 1910 |
"fold1 f A == THE x. fold1Set f A x" |
15506 | 1911 |
|
1912 |
lemma fold1Set_nonempty: |
|
22917 | 1913 |
"fold1Set f A x \<Longrightarrow> A \<noteq> {}" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1914 |
by(erule fold1Set.cases, simp_all) |
15392 | 1915 |
|
23736 | 1916 |
inductive_cases empty_fold1SetE [elim!]: "fold1Set f {} x" |
1917 |
||
1918 |
inductive_cases insert_fold1SetE [elim!]: "fold1Set f (insert a X) x" |
|
22262 | 1919 |
|
1920 |
||
1921 |
lemma fold1Set_sing [iff]: "(fold1Set f {a} b) = (a = b)" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1922 |
by (blast intro: fold_graph.intros elim: fold_graph.cases) |
15392 | 1923 |
|
22917 | 1924 |
lemma fold1_singleton [simp]: "fold1 f {a} = a" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1925 |
by (unfold fold1_def) blast |
12396 | 1926 |
|
15508 | 1927 |
lemma finite_nonempty_imp_fold1Set: |
22262 | 1928 |
"\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> EX x. fold1Set f A x" |
15508 | 1929 |
apply (induct A rule: finite_induct) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1930 |
apply (auto dest: finite_imp_fold_graph [of _ f]) |
15508 | 1931 |
done |
15506 | 1932 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1933 |
text{*First, some lemmas about @{const fold_graph}.*} |
15392 | 1934 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1935 |
context ab_semigroup_mult |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1936 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1937 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1938 |
lemma fun_left_comm: "fun_left_comm(op *)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1939 |
by unfold_locales (simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1940 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1941 |
lemma fold_graph_insert_swap: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1942 |
assumes fold: "fold_graph times (b::'a) A y" and "b \<notin> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1943 |
shows "fold_graph times z (insert b A) (z * y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1944 |
proof - |
29223 | 1945 |
interpret fun_left_comm "op *::'a \<Rightarrow> 'a \<Rightarrow> 'a" by (rule fun_left_comm) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1946 |
from assms show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1947 |
proof (induct rule: fold_graph.induct) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1948 |
case emptyI thus ?case by (force simp add: fold_insert_aux mult_commute) |
15508 | 1949 |
next |
22262 | 1950 |
case (insertI x A y) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1951 |
have "fold_graph times z (insert x (insert b A)) (x * (z * y))" |
15521 | 1952 |
using insertI by force --{*how does @{term id} get unfolded?*} |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1953 |
thus ?case by (simp add: insert_commute mult_ac) |
15508 | 1954 |
qed |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1955 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1956 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1957 |
lemma fold_graph_permute_diff: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1958 |
assumes fold: "fold_graph times b A x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1959 |
shows "!!a. \<lbrakk>a \<in> A; b \<notin> A\<rbrakk> \<Longrightarrow> fold_graph times a (insert b (A-{a})) x" |
15508 | 1960 |
using fold |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1961 |
proof (induct rule: fold_graph.induct) |
15508 | 1962 |
case emptyI thus ?case by simp |
1963 |
next |
|
22262 | 1964 |
case (insertI x A y) |
15521 | 1965 |
have "a = x \<or> a \<in> A" using insertI by simp |
1966 |
thus ?case |
|
1967 |
proof |
|
1968 |
assume "a = x" |
|
1969 |
with insertI show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1970 |
by (simp add: id_def [symmetric], blast intro: fold_graph_insert_swap) |
15521 | 1971 |
next |
1972 |
assume ainA: "a \<in> A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1973 |
hence "fold_graph times a (insert x (insert b (A - {a}))) (x * y)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1974 |
using insertI by force |
15521 | 1975 |
moreover |
1976 |
have "insert x (insert b (A - {a})) = insert b (insert x A - {a})" |
|
1977 |
using ainA insertI by blast |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1978 |
ultimately show ?thesis by simp |
15508 | 1979 |
qed |
1980 |
qed |
|
1981 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1982 |
lemma fold1_eq_fold: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1983 |
assumes "finite A" "a \<notin> A" shows "fold1 times (insert a A) = fold times a A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1984 |
proof - |
29223 | 1985 |
interpret fun_left_comm "op *::'a \<Rightarrow> 'a \<Rightarrow> 'a" by (rule fun_left_comm) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1986 |
from assms show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1987 |
apply (simp add: fold1_def fold_def) |
15508 | 1988 |
apply (rule the_equality) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1989 |
apply (best intro: fold_graph_determ theI dest: finite_imp_fold_graph [of _ times]) |
15508 | 1990 |
apply (rule sym, clarify) |
1991 |
apply (case_tac "Aa=A") |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1992 |
apply (best intro: the_equality fold_graph_determ) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1993 |
apply (subgoal_tac "fold_graph times a A x") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1994 |
apply (best intro: the_equality fold_graph_determ) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1995 |
apply (subgoal_tac "insert aa (Aa - {a}) = A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1996 |
prefer 2 apply (blast elim: equalityE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1997 |
apply (auto dest: fold_graph_permute_diff [where a=a]) |
15508 | 1998 |
done |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1999 |
qed |
15508 | 2000 |
|
15521 | 2001 |
lemma nonempty_iff: "(A \<noteq> {}) = (\<exists>x B. A = insert x B & x \<notin> B)" |
2002 |
apply safe |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2003 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2004 |
apply (drule_tac x=x in spec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2005 |
apply (drule_tac x="A-{x}" in spec, auto) |
15508 | 2006 |
done |
2007 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2008 |
lemma fold1_insert: |
15521 | 2009 |
assumes nonempty: "A \<noteq> {}" and A: "finite A" "x \<notin> A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2010 |
shows "fold1 times (insert x A) = x * fold1 times A" |
15521 | 2011 |
proof - |
29223 | 2012 |
interpret fun_left_comm "op *::'a \<Rightarrow> 'a \<Rightarrow> 'a" by (rule fun_left_comm) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2013 |
from nonempty obtain a A' where "A = insert a A' & a ~: A'" |
15521 | 2014 |
by (auto simp add: nonempty_iff) |
2015 |
with A show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2016 |
by (simp add: insert_commute [of x] fold1_eq_fold eq_commute) |
15521 | 2017 |
qed |
2018 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2019 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2020 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2021 |
context ab_semigroup_idem_mult |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2022 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2023 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2024 |
lemma fun_left_comm_idem: "fun_left_comm_idem(op *)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2025 |
apply unfold_locales |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2026 |
apply (simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2027 |
apply (simp add: mult_idem mult_assoc[symmetric]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2028 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2029 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2030 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2031 |
lemma fold1_insert_idem [simp]: |
15521 | 2032 |
assumes nonempty: "A \<noteq> {}" and A: "finite A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2033 |
shows "fold1 times (insert x A) = x * fold1 times A" |
15521 | 2034 |
proof - |
29223 | 2035 |
interpret fun_left_comm_idem "op *::'a \<Rightarrow> 'a \<Rightarrow> 'a" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2036 |
by (rule fun_left_comm_idem) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2037 |
from nonempty obtain a A' where A': "A = insert a A' & a ~: A'" |
15521 | 2038 |
by (auto simp add: nonempty_iff) |
2039 |
show ?thesis |
|
2040 |
proof cases |
|
2041 |
assume "a = x" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2042 |
thus ?thesis |
15521 | 2043 |
proof cases |
2044 |
assume "A' = {}" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2045 |
with prems show ?thesis by (simp add: mult_idem) |
15521 | 2046 |
next |
2047 |
assume "A' \<noteq> {}" |
|
2048 |
with prems show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2049 |
by (simp add: fold1_insert mult_assoc [symmetric] mult_idem) |
15521 | 2050 |
qed |
2051 |
next |
|
2052 |
assume "a \<noteq> x" |
|
2053 |
with prems show ?thesis |
|
2054 |
by (simp add: insert_commute fold1_eq_fold fold_insert_idem) |
|
2055 |
qed |
|
2056 |
qed |
|
15506 | 2057 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2058 |
lemma hom_fold1_commute: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2059 |
assumes hom: "!!x y. h (x * y) = h x * h y" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2060 |
and N: "finite N" "N \<noteq> {}" shows "h (fold1 times N) = fold1 times (h ` N)" |
22917 | 2061 |
using N proof (induct rule: finite_ne_induct) |
2062 |
case singleton thus ?case by simp |
|
2063 |
next |
|
2064 |
case (insert n N) |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2065 |
then have "h (fold1 times (insert n N)) = h (n * fold1 times N)" by simp |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2066 |
also have "\<dots> = h n * h (fold1 times N)" by(rule hom) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2067 |
also have "h (fold1 times N) = fold1 times (h ` N)" by(rule insert) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2068 |
also have "times (h n) \<dots> = fold1 times (insert (h n) (h ` N))" |
22917 | 2069 |
using insert by(simp) |
2070 |
also have "insert (h n) (h ` N) = h ` insert n N" by simp |
|
2071 |
finally show ?case . |
|
2072 |
qed |
|
2073 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2074 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2075 |
|
15506 | 2076 |
|
15508 | 2077 |
text{* Now the recursion rules for definitions: *} |
2078 |
||
22917 | 2079 |
lemma fold1_singleton_def: "g = fold1 f \<Longrightarrow> g {a} = a" |
15508 | 2080 |
by(simp add:fold1_singleton) |
2081 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2082 |
lemma (in ab_semigroup_mult) fold1_insert_def: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2083 |
"\<lbrakk> g = fold1 times; finite A; x \<notin> A; A \<noteq> {} \<rbrakk> \<Longrightarrow> g (insert x A) = x * g A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2084 |
by (simp add:fold1_insert) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2085 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2086 |
lemma (in ab_semigroup_idem_mult) fold1_insert_idem_def: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2087 |
"\<lbrakk> g = fold1 times; finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> g (insert x A) = x * g A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2088 |
by simp |
15508 | 2089 |
|
2090 |
subsubsection{* Determinacy for @{term fold1Set} *} |
|
2091 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2092 |
(*Not actually used!!*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2093 |
(* |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2094 |
context ab_semigroup_mult |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2095 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2096 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2097 |
lemma fold_graph_permute: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2098 |
"[|fold_graph times id b (insert a A) x; a \<notin> A; b \<notin> A|] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2099 |
==> fold_graph times id a (insert b A) x" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2100 |
apply (cases "a=b") |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2101 |
apply (auto dest: fold_graph_permute_diff) |
15506 | 2102 |
done |
15376 | 2103 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2104 |
lemma fold1Set_determ: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2105 |
"fold1Set times A x ==> fold1Set times A y ==> y = x" |
15506 | 2106 |
proof (clarify elim!: fold1Set.cases) |
2107 |
fix A x B y a b |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2108 |
assume Ax: "fold_graph times id a A x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2109 |
assume By: "fold_graph times id b B y" |
15506 | 2110 |
assume anotA: "a \<notin> A" |
2111 |
assume bnotB: "b \<notin> B" |
|
2112 |
assume eq: "insert a A = insert b B" |
|
2113 |
show "y=x" |
|
2114 |
proof cases |
|
2115 |
assume same: "a=b" |
|
2116 |
hence "A=B" using anotA bnotB eq by (blast elim!: equalityE) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2117 |
thus ?thesis using Ax By same by (blast intro: fold_graph_determ) |
15392 | 2118 |
next |
15506 | 2119 |
assume diff: "a\<noteq>b" |
2120 |
let ?D = "B - {a}" |
|
2121 |
have B: "B = insert a ?D" and A: "A = insert b ?D" |
|
2122 |
and aB: "a \<in> B" and bA: "b \<in> A" |
|
2123 |
using eq anotA bnotB diff by (blast elim!:equalityE)+ |
|
2124 |
with aB bnotB By |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2125 |
have "fold_graph times id a (insert b ?D) y" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2126 |
by (auto intro: fold_graph_permute simp add: insert_absorb) |
15506 | 2127 |
moreover |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2128 |
have "fold_graph times id a (insert b ?D) x" |
15506 | 2129 |
by (simp add: A [symmetric] Ax) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2130 |
ultimately show ?thesis by (blast intro: fold_graph_determ) |
15392 | 2131 |
qed |
12396 | 2132 |
qed |
2133 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2134 |
lemma fold1Set_equality: "fold1Set times A y ==> fold1 times A = y" |
15506 | 2135 |
by (unfold fold1_def) (blast intro: fold1Set_determ) |
2136 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2137 |
end |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2138 |
*) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2139 |
|
15506 | 2140 |
declare |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2141 |
empty_fold_graphE [rule del] fold_graph.intros [rule del] |
15506 | 2142 |
empty_fold1SetE [rule del] insert_fold1SetE [rule del] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19870
diff
changeset
|
2143 |
-- {* No more proofs involve these relations. *} |
15376 | 2144 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2145 |
subsubsection {* Lemmas about @{text fold1} *} |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2146 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2147 |
context ab_semigroup_mult |
22917 | 2148 |
begin |
2149 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2150 |
lemma fold1_Un: |
15484 | 2151 |
assumes A: "finite A" "A \<noteq> {}" |
2152 |
shows "finite B \<Longrightarrow> B \<noteq> {} \<Longrightarrow> A Int B = {} \<Longrightarrow> |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2153 |
fold1 times (A Un B) = fold1 times A * fold1 times B" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2154 |
using A by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2155 |
(simp_all add: fold1_insert mult_assoc) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2156 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2157 |
lemma fold1_in: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2158 |
assumes A: "finite (A)" "A \<noteq> {}" and elem: "\<And>x y. x * y \<in> {x,y}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2159 |
shows "fold1 times A \<in> A" |
15484 | 2160 |
using A |
2161 |
proof (induct rule:finite_ne_induct) |
|
15506 | 2162 |
case singleton thus ?case by simp |
15484 | 2163 |
next |
2164 |
case insert thus ?case using elem by (force simp add:fold1_insert) |
|
2165 |
qed |
|
2166 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2167 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2168 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2169 |
lemma (in ab_semigroup_idem_mult) fold1_Un2: |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2170 |
assumes A: "finite A" "A \<noteq> {}" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2171 |
shows "finite B \<Longrightarrow> B \<noteq> {} \<Longrightarrow> |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2172 |
fold1 times (A Un B) = fold1 times A * fold1 times B" |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2173 |
using A |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2174 |
proof(induct rule:finite_ne_induct) |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2175 |
case singleton thus ?case by simp |
15484 | 2176 |
next |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2177 |
case insert thus ?case by (simp add: mult_assoc) |
18423 | 2178 |
qed |
2179 |
||
2180 |
||
22917 | 2181 |
subsubsection {* Fold1 in lattices with @{const inf} and @{const sup} *} |
2182 |
||
2183 |
text{* |
|
2184 |
As an application of @{text fold1} we define infimum |
|
2185 |
and supremum in (not necessarily complete!) lattices |
|
2186 |
over (non-empty) sets by means of @{text fold1}. |
|
2187 |
*} |
|
2188 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2189 |
context lower_semilattice |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2190 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2191 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2192 |
lemma ab_semigroup_idem_mult_inf: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2193 |
"ab_semigroup_idem_mult inf" |
28823 | 2194 |
proof qed (rule inf_assoc inf_commute inf_idem)+ |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2195 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2196 |
lemma below_fold1_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2197 |
assumes "finite A" "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2198 |
shows "x \<le> fold1 inf A \<longleftrightarrow> (\<forall>a\<in>A. x \<le> a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2199 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2200 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2201 |
by (rule ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2202 |
show ?thesis using assms by (induct rule: finite_ne_induct) simp_all |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2203 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2204 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2205 |
lemma fold1_belowI: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2206 |
assumes "finite A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2207 |
and "a \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2208 |
shows "fold1 inf A \<le> a" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2209 |
proof - |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2210 |
from assms have "A \<noteq> {}" by auto |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2211 |
from `finite A` `A \<noteq> {}` `a \<in> A` show ?thesis |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2212 |
proof (induct rule: finite_ne_induct) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2213 |
case singleton thus ?case by simp |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2214 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2215 |
interpret ab_semigroup_idem_mult inf |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2216 |
by (rule ab_semigroup_idem_mult_inf) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2217 |
case (insert x F) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2218 |
from insert(5) have "a = x \<or> a \<in> F" by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2219 |
thus ?case |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2220 |
proof |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2221 |
assume "a = x" thus ?thesis using insert |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2222 |
by (simp add: mult_ac_idem) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2223 |
next |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2224 |
assume "a \<in> F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2225 |
hence bel: "fold1 inf F \<le> a" by (rule insert) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2226 |
have "inf (fold1 inf (insert x F)) a = inf x (inf (fold1 inf F) a)" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2227 |
using insert by (simp add: mult_ac_idem) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2228 |
also have "inf (fold1 inf F) a = fold1 inf F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2229 |
using bel by (auto intro: antisym) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2230 |
also have "inf x \<dots> = fold1 inf (insert x F)" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2231 |
using insert by (simp add: mult_ac_idem) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2232 |
finally have aux: "inf (fold1 inf (insert x F)) a = fold1 inf (insert x F)" . |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2233 |
moreover have "inf (fold1 inf (insert x F)) a \<le> a" by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2234 |
ultimately show ?thesis by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2235 |
qed |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2236 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2237 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2238 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2239 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2240 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2241 |
lemma (in upper_semilattice) ab_semigroup_idem_mult_sup: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2242 |
"ab_semigroup_idem_mult sup" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2243 |
by (rule lower_semilattice.ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2244 |
(rule dual_lattice) |
15500 | 2245 |
|
24342 | 2246 |
context lattice |
22917 | 2247 |
begin |
2248 |
||
2249 |
definition |
|
24342 | 2250 |
Inf_fin :: "'a set \<Rightarrow> 'a" ("\<Sqinter>\<^bsub>fin\<^esub>_" [900] 900) |
22917 | 2251 |
where |
25062 | 2252 |
"Inf_fin = fold1 inf" |
22917 | 2253 |
|
2254 |
definition |
|
24342 | 2255 |
Sup_fin :: "'a set \<Rightarrow> 'a" ("\<Squnion>\<^bsub>fin\<^esub>_" [900] 900) |
22917 | 2256 |
where |
25062 | 2257 |
"Sup_fin = fold1 sup" |
2258 |
||
2259 |
lemma Inf_le_Sup [simp]: "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> \<Sqinter>\<^bsub>fin\<^esub>A \<le> \<Squnion>\<^bsub>fin\<^esub>A" |
|
24342 | 2260 |
apply(unfold Sup_fin_def Inf_fin_def) |
15500 | 2261 |
apply(subgoal_tac "EX a. a:A") |
2262 |
prefer 2 apply blast |
|
2263 |
apply(erule exE) |
|
22388 | 2264 |
apply(rule order_trans) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2265 |
apply(erule (1) fold1_belowI) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2266 |
apply(erule (1) lower_semilattice.fold1_belowI [OF dual_lattice]) |
15500 | 2267 |
done |
2268 |
||
24342 | 2269 |
lemma sup_Inf_absorb [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2270 |
"finite A \<Longrightarrow> a \<in> A \<Longrightarrow> sup a (\<Sqinter>\<^bsub>fin\<^esub>A) = a" |
15512
ed1fa4617f52
Extracted generic lattice stuff to new Lattice_Locales.thy
nipkow
parents:
15510
diff
changeset
|
2271 |
apply(subst sup_commute) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2272 |
apply(simp add: Inf_fin_def sup_absorb2 fold1_belowI) |
15504 | 2273 |
done |
2274 |
||
24342 | 2275 |
lemma inf_Sup_absorb [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2276 |
"finite A \<Longrightarrow> a \<in> A \<Longrightarrow> inf a (\<Squnion>\<^bsub>fin\<^esub>A) = a" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2277 |
by (simp add: Sup_fin_def inf_absorb1 |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2278 |
lower_semilattice.fold1_belowI [OF dual_lattice]) |
24342 | 2279 |
|
2280 |
end |
|
2281 |
||
2282 |
context distrib_lattice |
|
2283 |
begin |
|
2284 |
||
2285 |
lemma sup_Inf1_distrib: |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2286 |
assumes "finite A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2287 |
and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2288 |
shows "sup x (\<Sqinter>\<^bsub>fin\<^esub>A) = \<Sqinter>\<^bsub>fin\<^esub>{sup x a|a. a \<in> A}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2289 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2290 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2291 |
by (rule ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2292 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2293 |
by (simp add: Inf_fin_def image_def |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2294 |
hom_fold1_commute [where h="sup x", OF sup_inf_distrib1]) |
26792 | 2295 |
(rule arg_cong [where f="fold1 inf"], blast) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2296 |
qed |
18423 | 2297 |
|
24342 | 2298 |
lemma sup_Inf2_distrib: |
2299 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
25062 | 2300 |
shows "sup (\<Sqinter>\<^bsub>fin\<^esub>A) (\<Sqinter>\<^bsub>fin\<^esub>B) = \<Sqinter>\<^bsub>fin\<^esub>{sup a b|a b. a \<in> A \<and> b \<in> B}" |
24342 | 2301 |
using A proof (induct rule: finite_ne_induct) |
15500 | 2302 |
case singleton thus ?case |
24342 | 2303 |
by (simp add: sup_Inf1_distrib [OF B] fold1_singleton_def [OF Inf_fin_def]) |
15500 | 2304 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2305 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2306 |
by (rule ab_semigroup_idem_mult_inf) |
15500 | 2307 |
case (insert x A) |
25062 | 2308 |
have finB: "finite {sup x b |b. b \<in> B}" |
2309 |
by(rule finite_surj[where f = "sup x", OF B(1)], auto) |
|
2310 |
have finAB: "finite {sup a b |a b. a \<in> A \<and> b \<in> B}" |
|
15500 | 2311 |
proof - |
25062 | 2312 |
have "{sup a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {sup a b})" |
15500 | 2313 |
by blast |
15517 | 2314 |
thus ?thesis by(simp add: insert(1) B(1)) |
15500 | 2315 |
qed |
25062 | 2316 |
have ne: "{sup a b |a b. a \<in> A \<and> b \<in> B} \<noteq> {}" using insert B by blast |
2317 |
have "sup (\<Sqinter>\<^bsub>fin\<^esub>(insert x A)) (\<Sqinter>\<^bsub>fin\<^esub>B) = sup (inf x (\<Sqinter>\<^bsub>fin\<^esub>A)) (\<Sqinter>\<^bsub>fin\<^esub>B)" |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2318 |
using insert by (simp add: fold1_insert_idem_def [OF Inf_fin_def]) |
25062 | 2319 |
also have "\<dots> = inf (sup x (\<Sqinter>\<^bsub>fin\<^esub>B)) (sup (\<Sqinter>\<^bsub>fin\<^esub>A) (\<Sqinter>\<^bsub>fin\<^esub>B))" by(rule sup_inf_distrib2) |
2320 |
also have "\<dots> = inf (\<Sqinter>\<^bsub>fin\<^esub>{sup x b|b. b \<in> B}) (\<Sqinter>\<^bsub>fin\<^esub>{sup a b|a b. a \<in> A \<and> b \<in> B})" |
|
15500 | 2321 |
using insert by(simp add:sup_Inf1_distrib[OF B]) |
25062 | 2322 |
also have "\<dots> = \<Sqinter>\<^bsub>fin\<^esub>({sup x b |b. b \<in> B} \<union> {sup a b |a b. a \<in> A \<and> b \<in> B})" |
24342 | 2323 |
(is "_ = \<Sqinter>\<^bsub>fin\<^esub>?M") |
15500 | 2324 |
using B insert |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2325 |
by (simp add: Inf_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 2326 |
also have "?M = {sup a b |a b. a \<in> insert x A \<and> b \<in> B}" |
15500 | 2327 |
by blast |
2328 |
finally show ?case . |
|
2329 |
qed |
|
2330 |
||
24342 | 2331 |
lemma inf_Sup1_distrib: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2332 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2333 |
shows "inf x (\<Squnion>\<^bsub>fin\<^esub>A) = \<Squnion>\<^bsub>fin\<^esub>{inf x a|a. a \<in> A}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2334 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2335 |
interpret ab_semigroup_idem_mult sup |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2336 |
by (rule ab_semigroup_idem_mult_sup) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2337 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2338 |
by (simp add: Sup_fin_def image_def hom_fold1_commute [where h="inf x", OF inf_sup_distrib1]) |
26792 | 2339 |
(rule arg_cong [where f="fold1 sup"], blast) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2340 |
qed |
18423 | 2341 |
|
24342 | 2342 |
lemma inf_Sup2_distrib: |
2343 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
25062 | 2344 |
shows "inf (\<Squnion>\<^bsub>fin\<^esub>A) (\<Squnion>\<^bsub>fin\<^esub>B) = \<Squnion>\<^bsub>fin\<^esub>{inf a b|a b. a \<in> A \<and> b \<in> B}" |
24342 | 2345 |
using A proof (induct rule: finite_ne_induct) |
18423 | 2346 |
case singleton thus ?case |
24342 | 2347 |
by(simp add: inf_Sup1_distrib [OF B] fold1_singleton_def [OF Sup_fin_def]) |
18423 | 2348 |
next |
2349 |
case (insert x A) |
|
25062 | 2350 |
have finB: "finite {inf x b |b. b \<in> B}" |
2351 |
by(rule finite_surj[where f = "%b. inf x b", OF B(1)], auto) |
|
2352 |
have finAB: "finite {inf a b |a b. a \<in> A \<and> b \<in> B}" |
|
18423 | 2353 |
proof - |
25062 | 2354 |
have "{inf a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {inf a b})" |
18423 | 2355 |
by blast |
2356 |
thus ?thesis by(simp add: insert(1) B(1)) |
|
2357 |
qed |
|
25062 | 2358 |
have ne: "{inf a b |a b. a \<in> A \<and> b \<in> B} \<noteq> {}" using insert B by blast |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2359 |
interpret ab_semigroup_idem_mult sup |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2360 |
by (rule ab_semigroup_idem_mult_sup) |
25062 | 2361 |
have "inf (\<Squnion>\<^bsub>fin\<^esub>(insert x A)) (\<Squnion>\<^bsub>fin\<^esub>B) = inf (sup x (\<Squnion>\<^bsub>fin\<^esub>A)) (\<Squnion>\<^bsub>fin\<^esub>B)" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2362 |
using insert by (simp add: fold1_insert_idem_def [OF Sup_fin_def]) |
25062 | 2363 |
also have "\<dots> = sup (inf x (\<Squnion>\<^bsub>fin\<^esub>B)) (inf (\<Squnion>\<^bsub>fin\<^esub>A) (\<Squnion>\<^bsub>fin\<^esub>B))" by(rule inf_sup_distrib2) |
2364 |
also have "\<dots> = sup (\<Squnion>\<^bsub>fin\<^esub>{inf x b|b. b \<in> B}) (\<Squnion>\<^bsub>fin\<^esub>{inf a b|a b. a \<in> A \<and> b \<in> B})" |
|
18423 | 2365 |
using insert by(simp add:inf_Sup1_distrib[OF B]) |
25062 | 2366 |
also have "\<dots> = \<Squnion>\<^bsub>fin\<^esub>({inf x b |b. b \<in> B} \<union> {inf a b |a b. a \<in> A \<and> b \<in> B})" |
24342 | 2367 |
(is "_ = \<Squnion>\<^bsub>fin\<^esub>?M") |
18423 | 2368 |
using B insert |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2369 |
by (simp add: Sup_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 2370 |
also have "?M = {inf a b |a b. a \<in> insert x A \<and> b \<in> B}" |
18423 | 2371 |
by blast |
2372 |
finally show ?case . |
|
2373 |
qed |
|
2374 |
||
24342 | 2375 |
end |
2376 |
||
2377 |
context complete_lattice |
|
2378 |
begin |
|
2379 |
||
22917 | 2380 |
text {* |
24342 | 2381 |
Coincidence on finite sets in complete lattices: |
22917 | 2382 |
*} |
2383 |
||
24342 | 2384 |
lemma Inf_fin_Inf: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2385 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2386 |
shows "\<Sqinter>\<^bsub>fin\<^esub>A = Inf A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2387 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2388 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2389 |
by (rule ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2390 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2391 |
unfolding Inf_fin_def by (induct A set: finite) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2392 |
(simp_all add: Inf_insert_simp) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2393 |
qed |
22917 | 2394 |
|
24342 | 2395 |
lemma Sup_fin_Sup: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2396 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2397 |
shows "\<Squnion>\<^bsub>fin\<^esub>A = Sup A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2398 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2399 |
interpret ab_semigroup_idem_mult sup |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2400 |
by (rule ab_semigroup_idem_mult_sup) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2401 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2402 |
unfolding Sup_fin_def by (induct A set: finite) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2403 |
(simp_all add: Sup_insert_simp) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2404 |
qed |
22917 | 2405 |
|
24342 | 2406 |
end |
2407 |
||
22917 | 2408 |
|
2409 |
subsubsection {* Fold1 in linear orders with @{const min} and @{const max} *} |
|
2410 |
||
2411 |
text{* |
|
2412 |
As an application of @{text fold1} we define minimum |
|
2413 |
and maximum in (not necessarily complete!) linear orders |
|
2414 |
over (non-empty) sets by means of @{text fold1}. |
|
2415 |
*} |
|
2416 |
||
24342 | 2417 |
context linorder |
22917 | 2418 |
begin |
2419 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2420 |
lemma ab_semigroup_idem_mult_min: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2421 |
"ab_semigroup_idem_mult min" |
28823 | 2422 |
proof qed (auto simp add: min_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2423 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2424 |
lemma ab_semigroup_idem_mult_max: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2425 |
"ab_semigroup_idem_mult max" |
28823 | 2426 |
proof qed (auto simp add: max_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2427 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2428 |
lemma min_lattice: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2429 |
"lower_semilattice (op \<le>) (op <) min" |
28823 | 2430 |
proof qed (auto simp add: min_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2431 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2432 |
lemma max_lattice: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2433 |
"lower_semilattice (op \<ge>) (op >) max" |
28823 | 2434 |
proof qed (auto simp add: max_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2435 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2436 |
lemma dual_max: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2437 |
"ord.max (op \<ge>) = min" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2438 |
by (auto simp add: ord.max_def_raw min_def_raw expand_fun_eq) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2439 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2440 |
lemma dual_min: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2441 |
"ord.min (op \<ge>) = max" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2442 |
by (auto simp add: ord.min_def_raw max_def_raw expand_fun_eq) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2443 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2444 |
lemma strict_below_fold1_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2445 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2446 |
shows "x < fold1 min A \<longleftrightarrow> (\<forall>a\<in>A. x < a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2447 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2448 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2449 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2450 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2451 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2452 |
(simp_all add: fold1_insert) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2453 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2454 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2455 |
lemma fold1_below_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2456 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2457 |
shows "fold1 min A \<le> x \<longleftrightarrow> (\<exists>a\<in>A. a \<le> x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2458 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2459 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2460 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2461 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2462 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2463 |
(simp_all add: fold1_insert min_le_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2464 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2465 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2466 |
lemma fold1_strict_below_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2467 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2468 |
shows "fold1 min A < x \<longleftrightarrow> (\<exists>a\<in>A. a < x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2469 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2470 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2471 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2472 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2473 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2474 |
(simp_all add: fold1_insert min_less_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2475 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2476 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2477 |
lemma fold1_antimono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2478 |
assumes "A \<noteq> {}" and "A \<subseteq> B" and "finite B" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2479 |
shows "fold1 min B \<le> fold1 min A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2480 |
proof cases |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2481 |
assume "A = B" thus ?thesis by simp |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2482 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2483 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2484 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2485 |
assume "A \<noteq> B" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2486 |
have B: "B = A \<union> (B-A)" using `A \<subseteq> B` by blast |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2487 |
have "fold1 min B = fold1 min (A \<union> (B-A))" by(subst B)(rule refl) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2488 |
also have "\<dots> = min (fold1 min A) (fold1 min (B-A))" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2489 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2490 |
have "finite A" by(rule finite_subset[OF `A \<subseteq> B` `finite B`]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2491 |
moreover have "finite(B-A)" by(rule finite_Diff[OF `finite B`]) (* by(blast intro:finite_Diff prems) fails *) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2492 |
moreover have "(B-A) \<noteq> {}" using prems by blast |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2493 |
moreover have "A Int (B-A) = {}" using prems by blast |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2494 |
ultimately show ?thesis using `A \<noteq> {}` by (rule_tac fold1_Un) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2495 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2496 |
also have "\<dots> \<le> fold1 min A" by (simp add: min_le_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2497 |
finally show ?thesis . |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2498 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2499 |
|
22917 | 2500 |
definition |
2501 |
Min :: "'a set \<Rightarrow> 'a" |
|
2502 |
where |
|
2503 |
"Min = fold1 min" |
|
2504 |
||
2505 |
definition |
|
2506 |
Max :: "'a set \<Rightarrow> 'a" |
|
2507 |
where |
|
2508 |
"Max = fold1 max" |
|
2509 |
||
2510 |
lemmas Min_singleton [simp] = fold1_singleton_def [OF Min_def] |
|
2511 |
lemmas Max_singleton [simp] = fold1_singleton_def [OF Max_def] |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2512 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2513 |
lemma Min_insert [simp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2514 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2515 |
shows "Min (insert x A) = min x (Min A)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2516 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2517 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2518 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2519 |
from assms show ?thesis by (rule fold1_insert_idem_def [OF Min_def]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2520 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2521 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2522 |
lemma Max_insert [simp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2523 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2524 |
shows "Max (insert x A) = max x (Max A)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2525 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2526 |
interpret ab_semigroup_idem_mult max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2527 |
by (rule ab_semigroup_idem_mult_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2528 |
from assms show ?thesis by (rule fold1_insert_idem_def [OF Max_def]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2529 |
qed |
15392 | 2530 |
|
24427 | 2531 |
lemma Min_in [simp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2532 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2533 |
shows "Min A \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2534 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2535 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2536 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2537 |
from assms fold1_in show ?thesis by (fastsimp simp: Min_def min_def) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2538 |
qed |
15392 | 2539 |
|
24427 | 2540 |
lemma Max_in [simp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2541 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2542 |
shows "Max A \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2543 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2544 |
interpret ab_semigroup_idem_mult max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2545 |
by (rule ab_semigroup_idem_mult_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2546 |
from assms fold1_in [of A] show ?thesis by (fastsimp simp: Max_def max_def) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2547 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2548 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2549 |
lemma Min_Un: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2550 |
assumes "finite A" and "A \<noteq> {}" and "finite B" and "B \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2551 |
shows "Min (A \<union> B) = min (Min A) (Min B)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2552 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2553 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2554 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2555 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2556 |
by (simp add: Min_def fold1_Un2) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2557 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2558 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2559 |
lemma Max_Un: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2560 |
assumes "finite A" and "A \<noteq> {}" and "finite B" and "B \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2561 |
shows "Max (A \<union> B) = max (Max A) (Max B)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2562 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2563 |
interpret ab_semigroup_idem_mult max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2564 |
by (rule ab_semigroup_idem_mult_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2565 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2566 |
by (simp add: Max_def fold1_Un2) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2567 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2568 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2569 |
lemma hom_Min_commute: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2570 |
assumes "\<And>x y. h (min x y) = min (h x) (h y)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2571 |
and "finite N" and "N \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2572 |
shows "h (Min N) = Min (h ` N)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2573 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2574 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2575 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2576 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2577 |
by (simp add: Min_def hom_fold1_commute) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2578 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2579 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2580 |
lemma hom_Max_commute: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2581 |
assumes "\<And>x y. h (max x y) = max (h x) (h y)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2582 |
and "finite N" and "N \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2583 |
shows "h (Max N) = Max (h ` N)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2584 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2585 |
interpret ab_semigroup_idem_mult max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2586 |
by (rule ab_semigroup_idem_mult_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2587 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2588 |
by (simp add: Max_def hom_fold1_commute [of h]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2589 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2590 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2591 |
lemma Min_le [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2592 |
assumes "finite A" and "x \<in> A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2593 |
shows "Min A \<le> x" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2594 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2595 |
interpret lower_semilattice "op \<le>" "op <" min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2596 |
by (rule min_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2597 |
from assms show ?thesis by (simp add: Min_def fold1_belowI) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2598 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2599 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2600 |
lemma Max_ge [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2601 |
assumes "finite A" and "x \<in> A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2602 |
shows "x \<le> Max A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2603 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2604 |
interpret lower_semilattice "op \<ge>" "op >" max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2605 |
by (rule max_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2606 |
from assms show ?thesis by (simp add: Max_def fold1_belowI) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2607 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2608 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2609 |
lemma Min_ge_iff [simp, noatp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2610 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2611 |
shows "x \<le> Min A \<longleftrightarrow> (\<forall>a\<in>A. x \<le> a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2612 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2613 |
interpret lower_semilattice "op \<le>" "op <" min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2614 |
by (rule min_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2615 |
from assms show ?thesis by (simp add: Min_def below_fold1_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2616 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2617 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2618 |
lemma Max_le_iff [simp, noatp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2619 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2620 |
shows "Max A \<le> x \<longleftrightarrow> (\<forall>a\<in>A. a \<le> x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2621 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2622 |
interpret lower_semilattice "op \<ge>" "op >" max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2623 |
by (rule max_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2624 |
from assms show ?thesis by (simp add: Max_def below_fold1_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2625 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2626 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2627 |
lemma Min_gr_iff [simp, noatp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2628 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2629 |
shows "x < Min A \<longleftrightarrow> (\<forall>a\<in>A. x < a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2630 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2631 |
interpret lower_semilattice "op \<le>" "op <" min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2632 |
by (rule min_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2633 |
from assms show ?thesis by (simp add: Min_def strict_below_fold1_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2634 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2635 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2636 |
lemma Max_less_iff [simp, noatp]: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2637 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2638 |
shows "Max A < x \<longleftrightarrow> (\<forall>a\<in>A. a < x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2639 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2640 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2641 |
interpret linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2642 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2643 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2644 |
by (simp add: Max strict_below_fold1_iff [folded dual_max]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2645 |
qed |
18493 | 2646 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
2647 |
lemma Min_le_iff [noatp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2648 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2649 |
shows "Min A \<le> x \<longleftrightarrow> (\<exists>a\<in>A. a \<le> x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2650 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2651 |
interpret lower_semilattice "op \<le>" "op <" min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2652 |
by (rule min_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2653 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2654 |
by (simp add: Min_def fold1_below_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2655 |
qed |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2656 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
2657 |
lemma Max_ge_iff [noatp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2658 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2659 |
shows "x \<le> Max A \<longleftrightarrow> (\<exists>a\<in>A. x \<le> a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2660 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2661 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2662 |
interpret linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2663 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2664 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2665 |
by (simp add: Max fold1_below_iff [folded dual_max]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2666 |
qed |
22917 | 2667 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
2668 |
lemma Min_less_iff [noatp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2669 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2670 |
shows "Min A < x \<longleftrightarrow> (\<exists>a\<in>A. a < x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2671 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2672 |
interpret lower_semilattice "op \<le>" "op <" min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2673 |
by (rule min_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2674 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2675 |
by (simp add: Min_def fold1_strict_below_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2676 |
qed |
22917 | 2677 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
2678 |
lemma Max_gr_iff [noatp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2679 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2680 |
shows "x < Max A \<longleftrightarrow> (\<exists>a\<in>A. x < a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2681 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2682 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2683 |
interpret linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2684 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2685 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2686 |
by (simp add: Max fold1_strict_below_iff [folded dual_max]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2687 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2688 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2689 |
lemma Min_antimono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2690 |
assumes "M \<subseteq> N" and "M \<noteq> {}" and "finite N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2691 |
shows "Min N \<le> Min M" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2692 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2693 |
interpret distrib_lattice "op \<le>" "op <" min max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2694 |
by (rule distrib_lattice_min_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2695 |
from assms show ?thesis by (simp add: Min_def fold1_antimono) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2696 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2697 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2698 |
lemma Max_mono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2699 |
assumes "M \<subseteq> N" and "M \<noteq> {}" and "finite N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2700 |
shows "Max M \<le> Max N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2701 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2702 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2703 |
interpret linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2704 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2705 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2706 |
by (simp add: Max fold1_antimono [folded dual_max]) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2707 |
qed |
22917 | 2708 |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2709 |
lemma finite_linorder_induct[consumes 1, case_names empty insert]: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2710 |
"finite A \<Longrightarrow> P {} \<Longrightarrow> |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2711 |
(!!A b. finite A \<Longrightarrow> ALL a:A. a < b \<Longrightarrow> P A \<Longrightarrow> P(insert b A)) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2712 |
\<Longrightarrow> P A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2713 |
proof (induct A rule: measure_induct_rule[where f=card]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2714 |
fix A :: "'a set" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2715 |
assume IH: "!! B. card B < card A \<Longrightarrow> finite B \<Longrightarrow> P {} \<Longrightarrow> |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2716 |
(!!A b. finite A \<Longrightarrow> (\<forall>a\<in>A. a<b) \<Longrightarrow> P A \<Longrightarrow> P (insert b A)) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2717 |
\<Longrightarrow> P B" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2718 |
and "finite A" and "P {}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2719 |
and step: "!!A b. \<lbrakk>finite A; \<forall>a\<in>A. a < b; P A\<rbrakk> \<Longrightarrow> P (insert b A)" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2720 |
show "P A" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2721 |
proof (cases "A = {}") |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2722 |
assume "A = {}" thus "P A" using `P {}` by simp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2723 |
next |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2724 |
let ?B = "A - {Max A}" let ?A = "insert (Max A) ?B" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2725 |
assume "A \<noteq> {}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2726 |
with `finite A` have "Max A : A" by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2727 |
hence A: "?A = A" using insert_Diff_single insert_absorb by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2728 |
note card_Diff1_less[OF `finite A` `Max A : A`] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2729 |
moreover have "finite ?B" using `finite A` by simp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2730 |
ultimately have "P ?B" using `P {}` step IH by blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2731 |
moreover have "\<forall>a\<in>?B. a < Max A" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2732 |
using Max_ge [OF `finite A`] by fastsimp |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2733 |
ultimately show "P A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2734 |
using A insert_Diff_single step[OF `finite ?B`] by fastsimp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2735 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2736 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
2737 |
|
22917 | 2738 |
end |
2739 |
||
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24342
diff
changeset
|
2740 |
context ordered_ab_semigroup_add |
22917 | 2741 |
begin |
2742 |
||
2743 |
lemma add_Min_commute: |
|
2744 |
fixes k |
|
25062 | 2745 |
assumes "finite N" and "N \<noteq> {}" |
2746 |
shows "k + Min N = Min {k + m | m. m \<in> N}" |
|
2747 |
proof - |
|
2748 |
have "\<And>x y. k + min x y = min (k + x) (k + y)" |
|
2749 |
by (simp add: min_def not_le) |
|
2750 |
(blast intro: antisym less_imp_le add_left_mono) |
|
2751 |
with assms show ?thesis |
|
2752 |
using hom_Min_commute [of "plus k" N] |
|
2753 |
by simp (blast intro: arg_cong [where f = Min]) |
|
2754 |
qed |
|
22917 | 2755 |
|
2756 |
lemma add_Max_commute: |
|
2757 |
fixes k |
|
25062 | 2758 |
assumes "finite N" and "N \<noteq> {}" |
2759 |
shows "k + Max N = Max {k + m | m. m \<in> N}" |
|
2760 |
proof - |
|
2761 |
have "\<And>x y. k + max x y = max (k + x) (k + y)" |
|
2762 |
by (simp add: max_def not_le) |
|
2763 |
(blast intro: antisym less_imp_le add_left_mono) |
|
2764 |
with assms show ?thesis |
|
2765 |
using hom_Max_commute [of "plus k" N] |
|
2766 |
by simp (blast intro: arg_cong [where f = Max]) |
|
2767 |
qed |
|
22917 | 2768 |
|
2769 |
end |
|
2770 |
||
25571
c9e39eafc7a0
instantiation target rather than legacy instance
haftmann
parents:
25502
diff
changeset
|
2771 |
end |