author | haftmann |
Fri, 05 Jun 2009 13:35:33 +0200 | |
changeset 31465 | 1ff89cc00898 |
parent 31451 | 960688121738 |
parent 31461 | d54b743b52a3 |
child 31768 | 159cd6b5e5d4 |
child 31906 | b41d61c768e2 |
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 |
29609 | 9 |
imports Nat Product_Type Power |
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 |
||
29923 | 96 |
text{* A finite choice principle. Does not need the SOME choice operator. *} |
97 |
lemma finite_set_choice: |
|
98 |
"finite A \<Longrightarrow> ALL x:A. (EX y. P x y) \<Longrightarrow> EX f. ALL x:A. P x (f x)" |
|
99 |
proof (induct set: finite) |
|
100 |
case empty thus ?case by simp |
|
101 |
next |
|
102 |
case (insert a A) |
|
103 |
then obtain f b where f: "ALL x:A. P x (f x)" and ab: "P a b" by auto |
|
104 |
show ?case (is "EX f. ?P f") |
|
105 |
proof |
|
106 |
show "?P(%x. if x = a then b else f x)" using f ab by auto |
|
107 |
qed |
|
108 |
qed |
|
109 |
||
23878 | 110 |
|
15392 | 111 |
text{* Finite sets are the images of initial segments of natural numbers: *} |
112 |
||
15510 | 113 |
lemma finite_imp_nat_seg_image_inj_on: |
114 |
assumes fin: "finite A" |
|
115 |
shows "\<exists> (n::nat) f. A = f ` {i. i<n} & inj_on f {i. i<n}" |
|
15392 | 116 |
using fin |
117 |
proof induct |
|
118 |
case empty |
|
15510 | 119 |
show ?case |
120 |
proof show "\<exists>f. {} = f ` {i::nat. i < 0} & inj_on f {i. i<0}" by simp |
|
121 |
qed |
|
15392 | 122 |
next |
123 |
case (insert a A) |
|
23389 | 124 |
have notinA: "a \<notin> A" by fact |
15510 | 125 |
from insert.hyps obtain n f |
126 |
where "A = f ` {i::nat. i < n}" "inj_on f {i. i < n}" by blast |
|
127 |
hence "insert a A = f(n:=a) ` {i. i < Suc n}" |
|
128 |
"inj_on (f(n:=a)) {i. i < Suc n}" using notinA |
|
129 |
by (auto simp add: image_def Ball_def inj_on_def less_Suc_eq) |
|
15392 | 130 |
thus ?case by blast |
131 |
qed |
|
132 |
||
133 |
lemma nat_seg_image_imp_finite: |
|
134 |
"!!f A. A = f ` {i::nat. i<n} \<Longrightarrow> finite A" |
|
135 |
proof (induct n) |
|
136 |
case 0 thus ?case by simp |
|
137 |
next |
|
138 |
case (Suc n) |
|
139 |
let ?B = "f ` {i. i < n}" |
|
140 |
have finB: "finite ?B" by(rule Suc.hyps[OF refl]) |
|
141 |
show ?case |
|
142 |
proof cases |
|
143 |
assume "\<exists>k<n. f n = f k" |
|
144 |
hence "A = ?B" using Suc.prems by(auto simp:less_Suc_eq) |
|
145 |
thus ?thesis using finB by simp |
|
146 |
next |
|
147 |
assume "\<not>(\<exists> k<n. f n = f k)" |
|
148 |
hence "A = insert (f n) ?B" using Suc.prems by(auto simp:less_Suc_eq) |
|
149 |
thus ?thesis using finB by simp |
|
150 |
qed |
|
151 |
qed |
|
152 |
||
153 |
lemma finite_conv_nat_seg_image: |
|
154 |
"finite A = (\<exists> (n::nat) f. A = f ` {i::nat. i<n})" |
|
15510 | 155 |
by(blast intro: nat_seg_image_imp_finite dest: finite_imp_nat_seg_image_inj_on) |
15392 | 156 |
|
29920 | 157 |
lemma finite_Collect_less_nat[iff]: "finite{n::nat. n<k}" |
158 |
by(fastsimp simp: finite_conv_nat_seg_image) |
|
159 |
||
26441 | 160 |
|
15392 | 161 |
subsubsection{* Finiteness and set theoretic constructions *} |
162 |
||
12396 | 163 |
lemma finite_UnI: "finite F ==> finite G ==> finite (F Un G)" |
29901 | 164 |
by (induct set: finite) simp_all |
12396 | 165 |
|
166 |
lemma finite_subset: "A \<subseteq> B ==> finite B ==> finite A" |
|
167 |
-- {* Every subset of a finite set is finite. *} |
|
168 |
proof - |
|
169 |
assume "finite B" |
|
170 |
thus "!!A. A \<subseteq> B ==> finite A" |
|
171 |
proof induct |
|
172 |
case empty |
|
173 |
thus ?case by simp |
|
174 |
next |
|
15327
0230a10582d3
changed the order of !!-quantifiers in finite set induction.
nipkow
parents:
15318
diff
changeset
|
175 |
case (insert x F A) |
23389 | 176 |
have A: "A \<subseteq> insert x F" and r: "A - {x} \<subseteq> F ==> finite (A - {x})" by fact+ |
12396 | 177 |
show "finite A" |
178 |
proof cases |
|
179 |
assume x: "x \<in> A" |
|
180 |
with A have "A - {x} \<subseteq> F" by (simp add: subset_insert_iff) |
|
181 |
with r have "finite (A - {x})" . |
|
182 |
hence "finite (insert x (A - {x}))" .. |
|
23389 | 183 |
also have "insert x (A - {x}) = A" using x by (rule insert_Diff) |
12396 | 184 |
finally show ?thesis . |
185 |
next |
|
23389 | 186 |
show "A \<subseteq> F ==> ?thesis" by fact |
12396 | 187 |
assume "x \<notin> A" |
188 |
with A show "A \<subseteq> F" by (simp add: subset_insert_iff) |
|
189 |
qed |
|
190 |
qed |
|
191 |
qed |
|
192 |
||
193 |
lemma finite_Un [iff]: "finite (F Un G) = (finite F & finite G)" |
|
29901 | 194 |
by (blast intro: finite_subset [of _ "X Un Y", standard] finite_UnI) |
195 |
||
29916 | 196 |
lemma finite_Collect_disjI[simp]: |
29901 | 197 |
"finite{x. P x | Q x} = (finite{x. P x} & finite{x. Q x})" |
198 |
by(simp add:Collect_disj_eq) |
|
12396 | 199 |
|
200 |
lemma finite_Int [simp, intro]: "finite F | finite G ==> finite (F Int G)" |
|
201 |
-- {* The converse obviously fails. *} |
|
29901 | 202 |
by (blast intro: finite_subset) |
203 |
||
29916 | 204 |
lemma finite_Collect_conjI [simp, intro]: |
29901 | 205 |
"finite{x. P x} | finite{x. Q x} ==> finite{x. P x & Q x}" |
206 |
-- {* The converse obviously fails. *} |
|
207 |
by(simp add:Collect_conj_eq) |
|
12396 | 208 |
|
29920 | 209 |
lemma finite_Collect_le_nat[iff]: "finite{n::nat. n<=k}" |
210 |
by(simp add: le_eq_less_or_eq) |
|
211 |
||
12396 | 212 |
lemma finite_insert [simp]: "finite (insert a A) = finite A" |
213 |
apply (subst insert_is_Un) |
|
14208 | 214 |
apply (simp only: finite_Un, blast) |
12396 | 215 |
done |
216 |
||
15281 | 217 |
lemma finite_Union[simp, intro]: |
218 |
"\<lbrakk> finite A; !!M. M \<in> A \<Longrightarrow> finite M \<rbrakk> \<Longrightarrow> finite(\<Union>A)" |
|
219 |
by (induct rule:finite_induct) simp_all |
|
220 |
||
12396 | 221 |
lemma finite_empty_induct: |
23389 | 222 |
assumes "finite A" |
223 |
and "P A" |
|
224 |
and "!!a A. finite A ==> a:A ==> P A ==> P (A - {a})" |
|
225 |
shows "P {}" |
|
12396 | 226 |
proof - |
227 |
have "P (A - A)" |
|
228 |
proof - |
|
23389 | 229 |
{ |
230 |
fix c b :: "'a set" |
|
231 |
assume c: "finite c" and b: "finite b" |
|
232 |
and P1: "P b" and P2: "!!x y. finite y ==> x \<in> y ==> P y ==> P (y - {x})" |
|
233 |
have "c \<subseteq> b ==> P (b - c)" |
|
234 |
using c |
|
235 |
proof induct |
|
236 |
case empty |
|
237 |
from P1 show ?case by simp |
|
238 |
next |
|
239 |
case (insert x F) |
|
240 |
have "P (b - F - {x})" |
|
241 |
proof (rule P2) |
|
242 |
from _ b show "finite (b - F)" by (rule finite_subset) blast |
|
243 |
from insert show "x \<in> b - F" by simp |
|
244 |
from insert show "P (b - F)" by simp |
|
245 |
qed |
|
246 |
also have "b - F - {x} = b - insert x F" by (rule Diff_insert [symmetric]) |
|
247 |
finally show ?case . |
|
12396 | 248 |
qed |
23389 | 249 |
} |
250 |
then show ?thesis by this (simp_all add: assms) |
|
12396 | 251 |
qed |
23389 | 252 |
then show ?thesis by simp |
12396 | 253 |
qed |
254 |
||
29901 | 255 |
lemma finite_Diff [simp]: "finite A ==> finite (A - B)" |
256 |
by (rule Diff_subset [THEN finite_subset]) |
|
257 |
||
258 |
lemma finite_Diff2 [simp]: |
|
259 |
assumes "finite B" shows "finite (A - B) = finite A" |
|
260 |
proof - |
|
261 |
have "finite A \<longleftrightarrow> finite((A-B) Un (A Int B))" by(simp add: Un_Diff_Int) |
|
262 |
also have "\<dots> \<longleftrightarrow> finite(A-B)" using `finite B` by(simp) |
|
263 |
finally show ?thesis .. |
|
264 |
qed |
|
265 |
||
266 |
lemma finite_compl[simp]: |
|
267 |
"finite(A::'a set) \<Longrightarrow> finite(-A) = finite(UNIV::'a set)" |
|
268 |
by(simp add:Compl_eq_Diff_UNIV) |
|
12396 | 269 |
|
29916 | 270 |
lemma finite_Collect_not[simp]: |
29903 | 271 |
"finite{x::'a. P x} \<Longrightarrow> finite{x. ~P x} = finite(UNIV::'a set)" |
272 |
by(simp add:Collect_neg_eq) |
|
273 |
||
12396 | 274 |
lemma finite_Diff_insert [iff]: "finite (A - insert a B) = finite (A - B)" |
275 |
apply (subst Diff_insert) |
|
276 |
apply (case_tac "a : A - B") |
|
277 |
apply (rule finite_insert [symmetric, THEN trans]) |
|
14208 | 278 |
apply (subst insert_Diff, simp_all) |
12396 | 279 |
done |
280 |
||
281 |
||
15392 | 282 |
text {* Image and Inverse Image over Finite Sets *} |
13825 | 283 |
|
284 |
lemma finite_imageI[simp]: "finite F ==> finite (h ` F)" |
|
285 |
-- {* The image of a finite set is finite. *} |
|
22262 | 286 |
by (induct set: finite) simp_all |
13825 | 287 |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
288 |
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
|
289 |
apply (frule finite_imageI) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
290 |
apply (erule finite_subset, assumption) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
291 |
done |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
292 |
|
13825 | 293 |
lemma finite_range_imageI: |
294 |
"finite (range g) ==> finite (range (%x. f (g x)))" |
|
27418 | 295 |
apply (drule finite_imageI, simp add: range_composition) |
13825 | 296 |
done |
297 |
||
12396 | 298 |
lemma finite_imageD: "finite (f`A) ==> inj_on f A ==> finite A" |
299 |
proof - |
|
300 |
have aux: "!!A. finite (A - {}) = finite A" by simp |
|
301 |
fix B :: "'a set" |
|
302 |
assume "finite B" |
|
303 |
thus "!!A. f`A = B ==> inj_on f A ==> finite A" |
|
304 |
apply induct |
|
305 |
apply simp |
|
306 |
apply (subgoal_tac "EX y:A. f y = x & F = f ` (A - {y})") |
|
307 |
apply clarify |
|
308 |
apply (simp (no_asm_use) add: inj_on_def) |
|
14208 | 309 |
apply (blast dest!: aux [THEN iffD1], atomize) |
12396 | 310 |
apply (erule_tac V = "ALL A. ?PP (A)" in thin_rl) |
14208 | 311 |
apply (frule subsetD [OF equalityD2 insertI1], clarify) |
12396 | 312 |
apply (rule_tac x = xa in bexI) |
313 |
apply (simp_all add: inj_on_image_set_diff) |
|
314 |
done |
|
315 |
qed (rule refl) |
|
316 |
||
317 |
||
13825 | 318 |
lemma inj_vimage_singleton: "inj f ==> f-`{a} \<subseteq> {THE x. f x = a}" |
319 |
-- {* The inverse image of a singleton under an injective function |
|
320 |
is included in a singleton. *} |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
321 |
apply (auto simp add: inj_on_def) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
322 |
apply (blast intro: the_equality [symmetric]) |
13825 | 323 |
done |
324 |
||
325 |
lemma finite_vimageI: "[|finite F; inj h|] ==> finite (h -` F)" |
|
326 |
-- {* The inverse image of a finite set under an injective function |
|
327 |
is finite. *} |
|
22262 | 328 |
apply (induct set: finite) |
21575 | 329 |
apply simp_all |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
330 |
apply (subst vimage_insert) |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
331 |
apply (simp add: finite_Un finite_subset [OF inj_vimage_singleton]) |
13825 | 332 |
done |
333 |
||
334 |
||
15392 | 335 |
text {* The finite UNION of finite sets *} |
12396 | 336 |
|
337 |
lemma finite_UN_I: "finite A ==> (!!a. a:A ==> finite (B a)) ==> finite (UN a:A. B a)" |
|
22262 | 338 |
by (induct set: finite) simp_all |
12396 | 339 |
|
340 |
text {* |
|
341 |
Strengthen RHS to |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
342 |
@{prop "((ALL x:A. finite (B x)) & finite {x. x:A & B x \<noteq> {}})"}? |
12396 | 343 |
|
344 |
We'd need to prove |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14331
diff
changeset
|
345 |
@{prop "finite C ==> ALL A B. (UNION A B) <= C --> finite {x. x:A & B x \<noteq> {}}"} |
12396 | 346 |
by induction. *} |
347 |
||
29918 | 348 |
lemma finite_UN [simp]: |
349 |
"finite A ==> finite (UNION A B) = (ALL x:A. finite (B x))" |
|
350 |
by (blast intro: finite_UN_I finite_subset) |
|
12396 | 351 |
|
29920 | 352 |
lemma finite_Collect_bex[simp]: "finite A \<Longrightarrow> |
353 |
finite{x. EX y:A. Q x y} = (ALL y:A. finite{x. Q x y})" |
|
354 |
apply(subgoal_tac "{x. EX y:A. Q x y} = UNION A (%y. {x. Q x y})") |
|
355 |
apply auto |
|
356 |
done |
|
357 |
||
358 |
lemma finite_Collect_bounded_ex[simp]: "finite{y. P y} \<Longrightarrow> |
|
359 |
finite{x. EX y. P y & Q x y} = (ALL y. P y \<longrightarrow> finite{x. Q x y})" |
|
360 |
apply(subgoal_tac "{x. EX y. P y & Q x y} = UNION {y. P y} (%y. {x. Q x y})") |
|
361 |
apply auto |
|
362 |
done |
|
363 |
||
364 |
||
17022 | 365 |
lemma finite_Plus: "[| finite A; finite B |] ==> finite (A <+> B)" |
366 |
by (simp add: Plus_def) |
|
367 |
||
31080 | 368 |
lemma finite_PlusD: |
369 |
fixes A :: "'a set" and B :: "'b set" |
|
370 |
assumes fin: "finite (A <+> B)" |
|
371 |
shows "finite A" "finite B" |
|
372 |
proof - |
|
373 |
have "Inl ` A \<subseteq> A <+> B" by auto |
|
374 |
hence "finite (Inl ` A :: ('a + 'b) set)" using fin by(rule finite_subset) |
|
375 |
thus "finite A" by(rule finite_imageD)(auto intro: inj_onI) |
|
376 |
next |
|
377 |
have "Inr ` B \<subseteq> A <+> B" by auto |
|
378 |
hence "finite (Inr ` B :: ('a + 'b) set)" using fin by(rule finite_subset) |
|
379 |
thus "finite B" by(rule finite_imageD)(auto intro: inj_onI) |
|
380 |
qed |
|
381 |
||
382 |
lemma finite_Plus_iff[simp]: "finite (A <+> B) \<longleftrightarrow> finite A \<and> finite B" |
|
383 |
by(auto intro: finite_PlusD finite_Plus) |
|
384 |
||
385 |
lemma finite_Plus_UNIV_iff[simp]: |
|
386 |
"finite (UNIV :: ('a + 'b) set) = |
|
387 |
(finite (UNIV :: 'a set) & finite (UNIV :: 'b set))" |
|
388 |
by(subst UNIV_Plus_UNIV[symmetric])(rule finite_Plus_iff) |
|
389 |
||
390 |
||
15392 | 391 |
text {* Sigma of finite sets *} |
12396 | 392 |
|
393 |
lemma finite_SigmaI [simp]: |
|
394 |
"finite A ==> (!!a. a:A ==> finite (B a)) ==> finite (SIGMA a:A. B a)" |
|
395 |
by (unfold Sigma_def) (blast intro!: finite_UN_I) |
|
396 |
||
15402 | 397 |
lemma finite_cartesian_product: "[| finite A; finite B |] ==> |
398 |
finite (A <*> B)" |
|
399 |
by (rule finite_SigmaI) |
|
400 |
||
12396 | 401 |
lemma finite_Prod_UNIV: |
402 |
"finite (UNIV::'a set) ==> finite (UNIV::'b set) ==> finite (UNIV::('a * 'b) set)" |
|
403 |
apply (subgoal_tac "(UNIV:: ('a * 'b) set) = Sigma UNIV (%x. UNIV)") |
|
404 |
apply (erule ssubst) |
|
14208 | 405 |
apply (erule finite_SigmaI, auto) |
12396 | 406 |
done |
407 |
||
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
408 |
lemma finite_cartesian_productD1: |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
409 |
"[| finite (A <*> B); B \<noteq> {} |] ==> finite A" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
410 |
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
|
411 |
apply (drule_tac x=n in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
412 |
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
|
413 |
apply (auto simp add: o_def) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
414 |
prefer 2 apply (force dest!: equalityD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
415 |
apply (drule equalityD1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
416 |
apply (rename_tac y x) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
417 |
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
|
418 |
prefer 2 apply force |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
419 |
apply clarify |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
420 |
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
|
421 |
done |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
422 |
|
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
423 |
lemma finite_cartesian_productD2: |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
424 |
"[| finite (A <*> B); A \<noteq> {} |] ==> finite B" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
425 |
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
|
426 |
apply (drule_tac x=n in spec) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
427 |
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
|
428 |
apply (auto simp add: o_def) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
429 |
prefer 2 apply (force dest!: equalityD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
430 |
apply (drule equalityD1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
431 |
apply (rename_tac x y) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
432 |
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
|
433 |
prefer 2 apply force |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
434 |
apply clarify |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
435 |
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
|
436 |
done |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
437 |
|
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
438 |
|
15392 | 439 |
text {* The powerset of a finite set *} |
12396 | 440 |
|
441 |
lemma finite_Pow_iff [iff]: "finite (Pow A) = finite A" |
|
442 |
proof |
|
443 |
assume "finite (Pow A)" |
|
444 |
with _ have "finite ((%x. {x}) ` A)" by (rule finite_subset) blast |
|
445 |
thus "finite A" by (rule finite_imageD [unfolded inj_on_def]) simp |
|
446 |
next |
|
447 |
assume "finite A" |
|
448 |
thus "finite (Pow A)" |
|
449 |
by induct (simp_all add: finite_UnI finite_imageI Pow_insert) |
|
450 |
qed |
|
451 |
||
29916 | 452 |
lemma finite_Collect_subsets[simp,intro]: "finite A \<Longrightarrow> finite{B. B \<subseteq> A}" |
453 |
by(simp add: Pow_def[symmetric]) |
|
15392 | 454 |
|
29918 | 455 |
|
15392 | 456 |
lemma finite_UnionD: "finite(\<Union>A) \<Longrightarrow> finite A" |
457 |
by(blast intro: finite_subset[OF subset_Pow_Union]) |
|
458 |
||
459 |
||
31441 | 460 |
lemma finite_subset_image: |
461 |
assumes "finite B" |
|
462 |
shows "B \<subseteq> f ` A \<Longrightarrow> \<exists>C\<subseteq>A. finite C \<and> B = f ` C" |
|
463 |
using assms proof(induct) |
|
464 |
case empty thus ?case by simp |
|
465 |
next |
|
466 |
case insert thus ?case |
|
467 |
by (clarsimp simp del: image_insert simp add: image_insert[symmetric]) |
|
468 |
blast |
|
469 |
qed |
|
470 |
||
471 |
||
26441 | 472 |
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
|
473 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
474 |
setup {* Sign.add_path "finite" *} -- {*FIXME: name tweaking*} |
29797 | 475 |
class 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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
|
27430 | 480 |
context finite |
481 |
begin |
|
482 |
||
483 |
lemma finite [simp]: "finite (A \<Colon> 'a set)" |
|
26441 | 484 |
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
|
485 |
|
27430 | 486 |
end |
487 |
||
26146 | 488 |
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
|
489 |
"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
|
490 |
|
26146 | 491 |
instance unit :: finite |
492 |
by default (simp add: UNIV_unit) |
|
493 |
||
494 |
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
|
495 |
"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
|
496 |
|
26146 | 497 |
instance bool :: finite |
498 |
by default (simp add: UNIV_bool) |
|
499 |
||
500 |
instance * :: (finite, finite) finite |
|
501 |
by default (simp only: UNIV_Times_UNIV [symmetric] finite_cartesian_product finite) |
|
502 |
||
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
|
503 |
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
|
504 |
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
|
505 |
|
26146 | 506 |
instance "fun" :: (finite, finite) finite |
507 |
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
|
508 |
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
|
509 |
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
|
510 |
let ?graph = "%f::'a => 'b. {(x, y). y = f x}" |
26792 | 511 |
have "range ?graph \<subseteq> Pow UNIV" by simp |
512 |
moreover have "finite (Pow (UNIV :: ('a * 'b) set))" |
|
513 |
by (simp only: finite_Pow_iff finite) |
|
514 |
ultimately show "finite (range ?graph)" |
|
515 |
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
|
516 |
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
|
517 |
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
|
518 |
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
|
519 |
|
27981 | 520 |
instance "+" :: (finite, finite) finite |
521 |
by default (simp only: UNIV_Plus_UNIV [symmetric] finite_Plus finite) |
|
522 |
||
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
|
523 |
|
15392 | 524 |
subsection {* A fold functional for finite sets *} |
525 |
||
526 |
text {* The intended behaviour is |
|
29966 | 527 |
@{text "fold f z {x\<^isub>1, ..., x\<^isub>n} = f x\<^isub>1 (\<dots> (f x\<^isub>n z)\<dots>)"} |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
528 |
if @{text f} is ``left-commutative'': |
15392 | 529 |
*} |
530 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
531 |
locale fun_left_comm = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
532 |
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
|
533 |
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
|
534 |
begin |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
535 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
536 |
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
|
537 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
538 |
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
|
539 |
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
|
540 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
541 |
end |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
542 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
\<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
|
548 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
549 |
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
|
550 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
551 |
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
|
552 |
[code del]: "fold f z A = (THE y. fold_graph f z A y)" |
15392 | 553 |
|
15498 | 554 |
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
|
555 |
@{term "if finite A then THE y. fold_graph f z A y else e"}. |
15498 | 556 |
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
|
557 |
@{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
|
558 |
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
|
559 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
560 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
561 |
lemma Diff1_fold_graph: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
562 |
"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
|
563 |
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
|
564 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
565 |
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
|
566 |
by (induct set: fold_graph) auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
567 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
568 |
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
|
569 |
by (induct set: finite) auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
570 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
571 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
572 |
subsubsection{*From @{const fold_graph} to @{term fold}*} |
15392 | 573 |
|
15510 | 574 |
lemma image_less_Suc: "h ` {i. i < Suc m} = insert (h m) (h ` {i. i < m})" |
19868 | 575 |
by (auto simp add: less_Suc_eq) |
15510 | 576 |
|
577 |
lemma insert_image_inj_on_eq: |
|
578 |
"[|insert (h m) A = h ` {i. i < Suc m}; h m \<notin> A; |
|
579 |
inj_on h {i. i < Suc m}|] |
|
580 |
==> A = h ` {i. i < m}" |
|
581 |
apply (auto simp add: image_less_Suc inj_on_def) |
|
582 |
apply (blast intro: less_trans) |
|
583 |
done |
|
584 |
||
585 |
lemma insert_inj_onE: |
|
586 |
assumes aA: "insert a A = h`{i::nat. i<n}" and anot: "a \<notin> A" |
|
587 |
and inj_on: "inj_on h {i::nat. i<n}" |
|
588 |
shows "\<exists>hm m. inj_on hm {i::nat. i<m} & A = hm ` {i. i<m} & m < n" |
|
589 |
proof (cases n) |
|
590 |
case 0 thus ?thesis using aA by auto |
|
591 |
next |
|
592 |
case (Suc m) |
|
23389 | 593 |
have nSuc: "n = Suc m" by fact |
15510 | 594 |
have mlessn: "m<n" by (simp add: nSuc) |
15532 | 595 |
from aA obtain k where hkeq: "h k = a" and klessn: "k<n" by (blast elim!: equalityE) |
27165 | 596 |
let ?hm = "Fun.swap k m h" |
15520 | 597 |
have inj_hm: "inj_on ?hm {i. i < n}" using klessn mlessn |
598 |
by (simp add: inj_on_swap_iff inj_on) |
|
15510 | 599 |
show ?thesis |
15520 | 600 |
proof (intro exI conjI) |
601 |
show "inj_on ?hm {i. i < m}" using inj_hm |
|
15510 | 602 |
by (auto simp add: nSuc less_Suc_eq intro: subset_inj_on) |
15520 | 603 |
show "m<n" by (rule mlessn) |
604 |
show "A = ?hm ` {i. i < m}" |
|
605 |
proof (rule insert_image_inj_on_eq) |
|
27165 | 606 |
show "inj_on (Fun.swap k m h) {i. i < Suc m}" using inj_hm nSuc by simp |
15520 | 607 |
show "?hm m \<notin> A" by (simp add: swap_def hkeq anot) |
608 |
show "insert (?hm m) A = ?hm ` {i. i < Suc m}" |
|
609 |
using aA hkeq nSuc klessn |
|
610 |
by (auto simp add: swap_def image_less_Suc fun_upd_image |
|
611 |
less_Suc_eq inj_on_image_set_diff [OF inj_on]) |
|
15479 | 612 |
qed |
613 |
qed |
|
614 |
qed |
|
615 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
616 |
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
|
617 |
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
|
618 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
619 |
lemma fold_graph_determ_aux: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
620 |
"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
|
621 |
\<Longrightarrow> fold_graph f z A x \<Longrightarrow> fold_graph f z A x' |
15392 | 622 |
\<Longrightarrow> x' = x" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
623 |
proof (induct n arbitrary: A x x' h rule: less_induct) |
15510 | 624 |
case (less n) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
625 |
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
|
626 |
\<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
|
627 |
\<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
|
628 |
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
|
629 |
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
|
630 |
show ?case |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
631 |
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
|
632 |
assume "A = {}" and "x = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
633 |
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
|
634 |
next |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
635 |
fix B b u |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
636 |
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
|
637 |
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
|
638 |
show "x'=x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
639 |
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
|
640 |
assume "A = {}" and "x' = z" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
641 |
with AbB show "x' = x" by blast |
15392 | 642 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
643 |
fix C c v |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
644 |
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
|
645 |
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
|
646 |
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
|
647 |
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
|
648 |
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
|
649 |
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
|
650 |
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
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
show "x'=x" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
655 |
proof cases |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
656 |
assume "b=c" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
by auto |
15392 | 660 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
661 |
assume diff: "b \<noteq> c" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
662 |
let ?D = "B - {c}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
moreover have "f b d = v" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
673 |
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
|
674 |
show "fold_graph f z C (f b d)" using C notinB Dfoldd by fastsimp |
15392 | 675 |
qed |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
676 |
ultimately show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
677 |
using fun_left_comm [of c b] x x' by (auto simp add: o_def) |
15392 | 678 |
qed |
679 |
qed |
|
680 |
qed |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
681 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
682 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
683 |
lemma fold_graph_determ: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
684 |
"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
|
685 |
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
|
686 |
apply (blast intro: fold_graph_determ_aux [rule_format]) |
15392 | 687 |
done |
688 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
689 |
lemma fold_equality: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
690 |
"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
|
691 |
by (unfold fold_def) (blast intro: fold_graph_determ) |
15392 | 692 |
|
693 |
text{* The base case for @{text fold}: *} |
|
694 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
695 |
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
|
696 |
by (unfold fold_def) blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
697 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
698 |
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
|
699 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
700 |
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
|
701 |
\<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
|
702 |
(\<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
|
703 |
apply auto |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
704 |
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
|
705 |
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
|
706 |
apply (blast intro: fold_graph_determ) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
707 |
done |
15392 | 708 |
|
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
|
709 |
lemma fold_insert [simp]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
710 |
"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
|
711 |
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
|
712 |
apply (rule the_equality) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
713 |
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
|
714 |
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
|
715 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
716 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
717 |
lemma fold_fun_comm: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
718 |
"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
|
719 |
proof (induct rule: finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
720 |
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
|
721 |
next |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
722 |
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
|
723 |
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
|
724 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
725 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
726 |
lemma fold_insert2: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
727 |
"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
|
728 |
by (simp add: fold_insert fold_fun_comm) |
15392 | 729 |
|
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
|
730 |
lemma fold_rec: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
731 |
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
|
732 |
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
|
733 |
proof - |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
by (rule fold_insert) (simp add: `finite A`)+ |
15535 | 738 |
finally show ?thesis . |
739 |
qed |
|
740 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
741 |
lemma fold_insert_remove: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
742 |
assumes "finite A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
743 |
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
|
744 |
proof - |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
by (rule fold_rec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
749 |
then show ?thesis by simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
750 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
751 |
|
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
|
752 |
end |
15392 | 753 |
|
15480 | 754 |
text{* A simplified version for idempotent functions: *} |
755 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
756 |
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
|
757 |
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
|
758 |
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
|
759 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
760 |
text{* The nice version: *} |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
761 |
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
|
762 |
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
|
763 |
|
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
|
764 |
lemma fold_insert_idem: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
765 |
assumes fin: "finite A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
766 |
shows "fold f z (insert x A) = f x (fold f z A)" |
15480 | 767 |
proof cases |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
768 |
assume "x \<in> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
769 |
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
|
770 |
then show ?thesis using assms by (simp add:fun_left_idem) |
15480 | 771 |
next |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
772 |
assume "x \<notin> A" then show ?thesis using assms by simp |
15480 | 773 |
qed |
774 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
775 |
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
|
776 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
777 |
lemma fold_insert_idem2: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
778 |
"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
|
779 |
by(simp add:fold_fun_comm) |
15484 | 780 |
|
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
|
781 |
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
|
782 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
783 |
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
|
784 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
785 |
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
|
786 |
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
|
787 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
788 |
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
|
789 |
by(simp add:fold_image_def) |
15392 | 790 |
|
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
|
791 |
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
|
792 |
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
|
793 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
794 |
lemma fold_image_insert[simp]: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
795 |
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
|
796 |
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
|
797 |
proof - |
29223 | 798 |
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
|
799 |
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
|
800 |
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
|
801 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
802 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
803 |
(* |
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
|
804 |
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
|
805 |
"finite A ==> (!!z. x * (fold times g z A) = fold times g (x * z) A)" |
22262 | 806 |
apply (induct set: finite) |
21575 | 807 |
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
|
808 |
apply (simp add: mult_left_commute [of x]) |
15392 | 809 |
done |
810 |
||
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
|
811 |
lemma fold_nest_Un_Int: |
15392 | 812 |
"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
|
813 |
==> fold times g (fold times g z B) A = fold times g (fold times g z (A Int B)) (A Un B)" |
22262 | 814 |
apply (induct set: finite) |
21575 | 815 |
apply simp |
15392 | 816 |
apply (simp add: fold_commute Int_insert_left insert_absorb) |
817 |
done |
|
818 |
||
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
|
819 |
lemma fold_nest_Un_disjoint: |
15392 | 820 |
"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
|
821 |
==> fold times g z (A Un B) = fold times g (fold times g z B) A" |
15392 | 822 |
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
|
823 |
*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
824 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
825 |
lemma fold_image_reindex: |
15487 | 826 |
assumes fin: "finite A" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
827 |
shows "inj_on h A \<Longrightarrow> fold_image times g z (h`A) = fold_image times (g\<circ>h) z A" |
15506 | 828 |
using fin apply induct |
15392 | 829 |
apply simp |
830 |
apply simp |
|
831 |
done |
|
832 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
833 |
(* |
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
|
834 |
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
|
835 |
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
|
836 |
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
|
837 |
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
|
838 |
*} |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
839 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
840 |
lemma fold_fusion: |
27611 | 841 |
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
|
842 |
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
|
843 |
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
|
844 |
shows "h (fold g j w A) = fold times j (h w) A" |
27611 | 845 |
proof - |
29223 | 846 |
class_interpret ab_semigroup_mult [g] by fact |
27611 | 847 |
show ?thesis using fin hyp by (induct set: finite) simp_all |
848 |
qed |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
849 |
*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
850 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
851 |
lemma fold_image_cong: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
852 |
"finite A \<Longrightarrow> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
853 |
(!!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
|
854 |
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
|
855 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
856 |
apply (erule finite_induct, simp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
857 |
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
|
858 |
apply (subgoal_tac "finite C") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
859 |
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
|
860 |
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
|
861 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
862 |
apply (erule ssubst) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
863 |
apply (drule spec) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
864 |
apply (erule (1) notE impE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
865 |
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
|
866 |
done |
15392 | 867 |
|
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
|
868 |
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
|
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 |
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
|
871 |
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
|
872 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
873 |
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
|
874 |
"finite A ==> finite B ==> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
875 |
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
|
876 |
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
|
877 |
by (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
878 |
(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
|
879 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
880 |
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
|
881 |
"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
|
882 |
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
|
883 |
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
|
884 |
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
|
885 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
886 |
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
|
887 |
"\<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
|
888 |
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
|
889 |
\<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
|
890 |
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
|
891 |
apply (induct set: finite, simp, atomize) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
892 |
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
|
893 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
894 |
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
|
895 |
prefer 2 apply blast |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
896 |
apply (simp add: fold_Un_disjoint) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
897 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
898 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
899 |
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
|
900 |
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
|
901 |
fold_image times (split g) 1 (SIGMA x:A. B x)" |
15392 | 902 |
apply (subst Sigma_def) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
903 |
apply (subst fold_image_UN_disjoint, assumption, simp) |
15392 | 904 |
apply blast |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
905 |
apply (erule fold_image_cong) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
906 |
apply (subst fold_image_UN_disjoint, simp, simp) |
15392 | 907 |
apply blast |
15506 | 908 |
apply simp |
15392 | 909 |
done |
910 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
911 |
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
|
912 |
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
|
913 |
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
|
914 |
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
|
915 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
916 |
lemma fold_image_related: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
917 |
assumes Re: "R e e" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
918 |
and Rop: "\<forall>x1 y1 x2 y2. R x1 x2 \<and> R y1 y2 \<longrightarrow> R (x1 * y1) (x2 * y2)" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
919 |
and fS: "finite S" and Rfg: "\<forall>x\<in>S. R (h x) (g x)" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
920 |
shows "R (fold_image (op *) h e S) (fold_image (op *) g e S)" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
921 |
using fS by (rule finite_subset_induct) (insert assms, auto) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
922 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
923 |
lemma fold_image_eq_general: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
924 |
assumes fS: "finite S" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
925 |
and h: "\<forall>y\<in>S'. \<exists>!x. x\<in> S \<and> h(x) = y" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
926 |
and f12: "\<forall>x\<in>S. h x \<in> S' \<and> f2(h x) = f1 x" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
927 |
shows "fold_image (op *) f1 e S = fold_image (op *) f2 e S'" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
928 |
proof- |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
929 |
from h f12 have hS: "h ` S = S'" by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
930 |
{fix x y assume H: "x \<in> S" "y \<in> S" "h x = h y" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
931 |
from f12 h H have "x = y" by auto } |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
932 |
hence hinj: "inj_on h S" unfolding inj_on_def Ex1_def by blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
933 |
from f12 have th: "\<And>x. x \<in> S \<Longrightarrow> (f2 \<circ> h) x = f1 x" by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
934 |
from hS have "fold_image (op *) f2 e S' = fold_image (op *) f2 e (h ` S)" by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
935 |
also have "\<dots> = fold_image (op *) (f2 o h) e S" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
936 |
using fold_image_reindex[OF fS hinj, of f2 e] . |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
937 |
also have "\<dots> = fold_image (op *) f1 e S " using th fold_image_cong[OF fS, of "f2 o h" f1 e] |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
938 |
by blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
939 |
finally show ?thesis .. |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
940 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
941 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
942 |
lemma fold_image_eq_general_inverses: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
943 |
assumes fS: "finite S" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
944 |
and kh: "\<And>y. y \<in> T \<Longrightarrow> k y \<in> S \<and> h (k y) = y" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
945 |
and hk: "\<And>x. x \<in> S \<Longrightarrow> h x \<in> T \<and> k (h x) = x \<and> g (h x) = f x" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
946 |
shows "fold_image (op *) f e S = fold_image (op *) g e T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
947 |
(* metis solves it, but not yet available here *) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
948 |
apply (rule fold_image_eq_general[OF fS, of T h g f e]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
949 |
apply (rule ballI) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
950 |
apply (frule kh) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
951 |
apply (rule ex1I[]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
952 |
apply blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
953 |
apply clarsimp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
954 |
apply (drule hk) apply simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
955 |
apply (rule sym) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
956 |
apply (erule conjunct1[OF conjunct2[OF hk]]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
957 |
apply (rule ballI) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
958 |
apply (drule hk) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
959 |
apply blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
960 |
done |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
961 |
|
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
|
962 |
end |
22917 | 963 |
|
15402 | 964 |
subsection {* Generalized summation over a set *} |
965 |
||
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
30325
diff
changeset
|
966 |
interpretation comm_monoid_add: comm_monoid_mult "0::'a::comm_monoid_add" "op +" |
28823 | 967 |
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
|
968 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
969 |
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
|
970 |
where "setsum f A == if finite A then fold_image (op +) f 0 A else 0" |
15402 | 971 |
|
19535 | 972 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
973 |
Setsum ("\<Sum>_" [1000] 999) where |
19535 | 974 |
"\<Sum>A == setsum (%x. x) A" |
975 |
||
15402 | 976 |
text{* Now: lot's of fancy syntax. First, @{term "setsum (%x. e) A"} is |
977 |
written @{text"\<Sum>x\<in>A. e"}. *} |
|
978 |
||
979 |
syntax |
|
17189 | 980 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3SUM _:_. _)" [0, 51, 10] 10) |
15402 | 981 |
syntax (xsymbols) |
17189 | 982 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 983 |
syntax (HTML output) |
17189 | 984 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 985 |
|
986 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
987 |
"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
|
988 |
"\<Sum>i\<in>A. b" == "CONST setsum (%i. b) A" |
15402 | 989 |
|
990 |
text{* Instead of @{term"\<Sum>x\<in>{x. P}. e"} we introduce the shorter |
|
991 |
@{text"\<Sum>x|P. e"}. *} |
|
992 |
||
993 |
syntax |
|
17189 | 994 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3SUM _ |/ _./ _)" [0,0,10] 10) |
15402 | 995 |
syntax (xsymbols) |
17189 | 996 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 997 |
syntax (HTML output) |
17189 | 998 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 999 |
|
1000 |
translations |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1001 |
"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
|
1002 |
"\<Sum>x|P. t" => "CONST setsum (%x. t) {x. P}" |
15402 | 1003 |
|
1004 |
print_translation {* |
|
1005 |
let |
|
19535 | 1006 |
fun setsum_tr' [Abs(x,Tx,t), Const ("Collect",_) $ Abs(y,Ty,P)] = |
1007 |
if x<>y then raise Match |
|
1008 |
else let val x' = Syntax.mark_bound x |
|
1009 |
val t' = subst_bound(x',t) |
|
1010 |
val P' = subst_bound(x',P) |
|
1011 |
in Syntax.const "_qsetsum" $ Syntax.mark_bound x $ P' $ t' end |
|
1012 |
in [("setsum", setsum_tr')] end |
|
15402 | 1013 |
*} |
1014 |
||
19535 | 1015 |
|
15402 | 1016 |
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
|
1017 |
by (simp add: setsum_def) |
15402 | 1018 |
|
1019 |
lemma setsum_insert [simp]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1020 |
"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
|
1021 |
by (simp add: setsum_def) |
15402 | 1022 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1023 |
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
|
1024 |
by (simp add: setsum_def) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1025 |
|
15402 | 1026 |
lemma setsum_reindex: |
1027 |
"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
|
1028 |
by(auto simp add: setsum_def comm_monoid_add.fold_image_reindex dest!:finite_imageD) |
15402 | 1029 |
|
1030 |
lemma setsum_reindex_id: |
|
1031 |
"inj_on f B ==> setsum f B = setsum id (f ` B)" |
|
1032 |
by (auto simp add: setsum_reindex) |
|
1033 |
||
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1034 |
lemma setsum_reindex_nonzero: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1035 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1036 |
and nz: "\<And> x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x \<noteq> y \<Longrightarrow> f x = f y \<Longrightarrow> h (f x) = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1037 |
shows "setsum h (f ` S) = setsum (h o f) S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1038 |
using nz |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1039 |
proof(induct rule: finite_induct[OF fS]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1040 |
case 1 thus ?case by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1041 |
next |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1042 |
case (2 x F) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1043 |
{assume fxF: "f x \<in> f ` F" hence "\<exists>y \<in> F . f y = f x" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1044 |
then obtain y where y: "y \<in> F" "f x = f y" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1045 |
from "2.hyps" y have xy: "x \<noteq> y" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1046 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1047 |
from "2.prems"[of x y] "2.hyps" xy y have h0: "h (f x) = 0" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1048 |
have "setsum h (f ` insert x F) = setsum h (f ` F)" using fxF by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1049 |
also have "\<dots> = setsum (h o f) (insert x F)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1050 |
unfolding setsum_insert[OF `finite F` `x\<notin>F`] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1051 |
using h0 |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1052 |
apply simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1053 |
apply (rule "2.hyps"(3)) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1054 |
apply (rule_tac y="y" in "2.prems") |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1055 |
apply simp_all |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1056 |
done |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1057 |
finally have ?case .} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1058 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1059 |
{assume fxF: "f x \<notin> f ` F" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1060 |
have "setsum h (f ` insert x F) = h (f x) + setsum h (f ` F)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1061 |
using fxF "2.hyps" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1062 |
also have "\<dots> = setsum (h o f) (insert x F)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1063 |
unfolding setsum_insert[OF `finite F` `x\<notin>F`] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1064 |
apply simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1065 |
apply (rule cong[OF refl[of "op + (h (f x))"]]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1066 |
apply (rule "2.hyps"(3)) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1067 |
apply (rule_tac y="y" in "2.prems") |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1068 |
apply simp_all |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1069 |
done |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1070 |
finally have ?case .} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1071 |
ultimately show ?case by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1072 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1073 |
|
15402 | 1074 |
lemma setsum_cong: |
1075 |
"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
|
1076 |
by(fastsimp simp: setsum_def intro: comm_monoid_add.fold_image_cong) |
15402 | 1077 |
|
16733
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
1078 |
lemma strong_setsum_cong[cong]: |
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
1079 |
"A = B ==> (!!x. x:B =simp=> f x = g x) |
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
1080 |
==> 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
|
1081 |
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
|
1082 |
|
15554 | 1083 |
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
|
1084 |
by (rule setsum_cong[OF refl], auto); |
15554 | 1085 |
|
15402 | 1086 |
lemma setsum_reindex_cong: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1087 |
"[|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
|
1088 |
==> setsum h B = setsum g A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1089 |
by (simp add: setsum_reindex cong: setsum_cong) |
15402 | 1090 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1091 |
|
15542 | 1092 |
lemma setsum_0[simp]: "setsum (%i. 0) A = 0" |
15402 | 1093 |
apply (clarsimp simp: setsum_def) |
15765 | 1094 |
apply (erule finite_induct, auto) |
15402 | 1095 |
done |
1096 |
||
15543 | 1097 |
lemma setsum_0': "ALL a:A. f a = 0 ==> setsum f A = 0" |
1098 |
by(simp add:setsum_cong) |
|
15402 | 1099 |
|
1100 |
lemma setsum_Un_Int: "finite A ==> finite B ==> |
|
1101 |
setsum g (A Un B) + setsum g (A Int B) = setsum g A + setsum g B" |
|
1102 |
-- {* 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
|
1103 |
by(simp add: setsum_def comm_monoid_add.fold_image_Un_Int [symmetric]) |
15402 | 1104 |
|
1105 |
lemma setsum_Un_disjoint: "finite A ==> finite B |
|
1106 |
==> A Int B = {} ==> setsum g (A Un B) = setsum g A + setsum g B" |
|
1107 |
by (subst setsum_Un_Int [symmetric], auto) |
|
1108 |
||
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1109 |
lemma setsum_mono_zero_left: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1110 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1111 |
and z: "\<forall>i \<in> T - S. f i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1112 |
shows "setsum f S = setsum f T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1113 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1114 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1115 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1116 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1117 |
show ?thesis |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1118 |
by (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] setsum_0'[OF z]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1119 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1120 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1121 |
lemma setsum_mono_zero_right: |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1122 |
"finite T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. f i = 0 \<Longrightarrow> setsum f T = setsum f S" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1123 |
by(blast intro!: setsum_mono_zero_left[symmetric]) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1124 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1125 |
lemma setsum_mono_zero_cong_left: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1126 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1127 |
and z: "\<forall>i \<in> T - S. g i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1128 |
and fg: "\<And>x. x \<in> S \<Longrightarrow> f x = g x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1129 |
shows "setsum f S = setsum g T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1130 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1131 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1132 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1133 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1134 |
show ?thesis |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1135 |
using fg by (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] setsum_0'[OF z]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1136 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1137 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1138 |
lemma setsum_mono_zero_cong_right: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1139 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1140 |
and z: "\<forall>i \<in> T - S. f i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1141 |
and fg: "\<And>x. x \<in> S \<Longrightarrow> f x = g x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1142 |
shows "setsum f T = setsum g S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1143 |
using setsum_mono_zero_cong_left[OF fT ST z] fg[symmetric] by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1144 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1145 |
lemma setsum_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1146 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1147 |
shows "setsum (\<lambda>k. if k=a then b k else 0) S = (if a \<in> S then b a else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1148 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1149 |
let ?f = "(\<lambda>k. if k=a then b k else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1150 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1151 |
hence "\<forall> k\<in> S. ?f k = 0" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1152 |
hence ?thesis using a by simp} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1153 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1154 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1155 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1156 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1157 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1158 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1159 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1160 |
have "setsum ?f S = setsum ?f ?A + setsum ?f ?B" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1161 |
using setsum_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1162 |
by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1163 |
then have ?thesis using a by simp} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1164 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1165 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1166 |
lemma setsum_delta': |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1167 |
assumes fS: "finite S" shows |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1168 |
"setsum (\<lambda>k. if a = k then b k else 0) S = |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1169 |
(if a\<in> S then b a else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1170 |
using setsum_delta[OF fS, of a b, symmetric] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1171 |
by (auto intro: setsum_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1172 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1173 |
lemma setsum_restrict_set: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1174 |
assumes fA: "finite A" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1175 |
shows "setsum f (A \<inter> B) = setsum (\<lambda>x. if x \<in> B then f x else 0) A" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1176 |
proof- |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1177 |
from fA have fab: "finite (A \<inter> B)" by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1178 |
have aba: "A \<inter> B \<subseteq> A" by blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1179 |
let ?g = "\<lambda>x. if x \<in> A\<inter>B then f x else 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1180 |
from setsum_mono_zero_left[OF fA aba, of ?g] |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1181 |
show ?thesis by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1182 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1183 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1184 |
lemma setsum_cases: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1185 |
assumes fA: "finite A" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1186 |
shows "setsum (\<lambda>x. if x \<in> B then f x else g x) A = |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1187 |
setsum f (A \<inter> B) + setsum g (A \<inter> - B)" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1188 |
proof- |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1189 |
have a: "A = A \<inter> B \<union> A \<inter> -B" "(A \<inter> B) \<inter> (A \<inter> -B) = {}" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1190 |
by blast+ |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1191 |
from fA |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1192 |
have f: "finite (A \<inter> B)" "finite (A \<inter> -B)" by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1193 |
let ?g = "\<lambda>x. if x \<in> B then f x else g x" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1194 |
from setsum_Un_disjoint[OF f a(2), of ?g] a(1) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1195 |
show ?thesis by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1196 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1197 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1198 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1199 |
(*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
|
1200 |
the lhs need not be, since UNION I A could still be finite.*) |
15402 | 1201 |
lemma setsum_UN_disjoint: |
1202 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
|
1203 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==> |
|
1204 |
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
|
1205 |
by(simp add: setsum_def comm_monoid_add.fold_image_UN_disjoint cong: setsum_cong) |
15402 | 1206 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1207 |
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
|
1208 |
directly 0, and @{term "Union C"} is also infinite, hence the lhs is also 0.*} |
15402 | 1209 |
lemma setsum_Union_disjoint: |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1210 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1211 |
(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
|
1212 |
==> setsum f (Union C) = setsum (setsum f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1213 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1214 |
prefer 2 apply (force dest: finite_UnionD simp add: setsum_def) |
15402 | 1215 |
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
|
1216 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1217 |
done |
15402 | 1218 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1219 |
(*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
|
1220 |
the rhs need not be, since SIGMA A B could still be finite.*) |
15402 | 1221 |
lemma setsum_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
17189 | 1222 |
(\<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
|
1223 |
by(simp add:setsum_def comm_monoid_add.fold_image_Sigma split_def cong:setsum_cong) |
15402 | 1224 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1225 |
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
|
1226 |
lemma setsum_cartesian_product: |
17189 | 1227 |
"(\<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
|
1228 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1229 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1230 |
apply (simp add: setsum_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1231 |
apply (cases "A={}", simp) |
15543 | 1232 |
apply (simp) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1233 |
apply (auto simp add: setsum_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1234 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1235 |
done |
15402 | 1236 |
|
1237 |
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
|
1238 |
by(simp add:setsum_def comm_monoid_add.fold_image_distrib) |
15402 | 1239 |
|
1240 |
||
1241 |
subsubsection {* Properties in more restricted classes of structures *} |
|
1242 |
||
1243 |
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
|
1244 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1245 |
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
|
1246 |
apply (erule rev_mp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1247 |
apply (erule finite_induct, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1248 |
done |
15402 | 1249 |
|
1250 |
lemma setsum_eq_0_iff [simp]: |
|
1251 |
"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
|
1252 |
by (induct set: finite) auto |
15402 | 1253 |
|
30859 | 1254 |
lemma setsum_eq_Suc0_iff: "finite A \<Longrightarrow> |
1255 |
(setsum f A = Suc 0) = (EX a:A. f a = Suc 0 & (ALL b:A. a\<noteq>b \<longrightarrow> f b = 0))" |
|
1256 |
apply(erule finite_induct) |
|
1257 |
apply (auto simp add:add_is_1) |
|
1258 |
done |
|
1259 |
||
1260 |
lemmas setsum_eq_1_iff = setsum_eq_Suc0_iff[simplified One_nat_def[symmetric]] |
|
1261 |
||
15402 | 1262 |
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
|
1263 |
(setsum f (A Un B) :: nat) = setsum f A + setsum f B - setsum f (A Int B)" |
15402 | 1264 |
-- {* For the natural numbers, we have subtraction. *} |
29667 | 1265 |
by (subst setsum_Un_Int [symmetric], auto simp add: algebra_simps) |
15402 | 1266 |
|
1267 |
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
|
1268 |
(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
|
1269 |
setsum f A + setsum f B - setsum f (A Int B)" |
29667 | 1270 |
by (subst setsum_Un_Int [symmetric], auto simp add: algebra_simps) |
15402 | 1271 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1272 |
lemma (in comm_monoid_mult) fold_image_1: "finite S \<Longrightarrow> (\<forall>x\<in>S. f x = 1) \<Longrightarrow> fold_image op * f 1 S = 1" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1273 |
apply (induct set: finite) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1274 |
apply simp by (auto simp add: fold_image_insert) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1275 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1276 |
lemma (in comm_monoid_mult) fold_image_Un_one: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1277 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1278 |
and I0: "\<forall>x \<in> S\<inter>T. f x = 1" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1279 |
shows "fold_image (op *) f 1 (S \<union> T) = fold_image (op *) f 1 S * fold_image (op *) f 1 T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1280 |
proof- |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1281 |
have "fold_image op * f 1 (S \<inter> T) = 1" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1282 |
apply (rule fold_image_1) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1283 |
using fS fT I0 by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1284 |
with fold_image_Un_Int[OF fS fT] show ?thesis by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1285 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1286 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1287 |
lemma setsum_eq_general_reverses: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1288 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1289 |
and kh: "\<And>y. y \<in> T \<Longrightarrow> k y \<in> S \<and> h (k y) = y" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1290 |
and hk: "\<And>x. x \<in> S \<Longrightarrow> h x \<in> T \<and> k (h x) = x \<and> g (h x) = f x" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1291 |
shows "setsum f S = setsum g T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1292 |
apply (simp add: setsum_def fS fT) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1293 |
apply (rule comm_monoid_add.fold_image_eq_general_inverses[OF fS]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1294 |
apply (erule kh) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1295 |
apply (erule hk) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1296 |
done |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1297 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1298 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1299 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1300 |
lemma setsum_Un_zero: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1301 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1302 |
and I0: "\<forall>x \<in> S\<inter>T. f x = 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1303 |
shows "setsum f (S \<union> T) = setsum f S + setsum f T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1304 |
using fS fT |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1305 |
apply (simp add: setsum_def) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1306 |
apply (rule comm_monoid_add.fold_image_Un_one) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1307 |
using I0 by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1308 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1309 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1310 |
lemma setsum_UNION_zero: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1311 |
assumes fS: "finite S" and fSS: "\<forall>T \<in> S. finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1312 |
and f0: "\<And>T1 T2 x. T1\<in>S \<Longrightarrow> T2\<in>S \<Longrightarrow> T1 \<noteq> T2 \<Longrightarrow> x \<in> T1 \<Longrightarrow> x \<in> T2 \<Longrightarrow> f x = 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1313 |
shows "setsum f (\<Union>S) = setsum (\<lambda>T. setsum f T) S" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1314 |
using fSS f0 |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1315 |
proof(induct rule: finite_induct[OF fS]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1316 |
case 1 thus ?case by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1317 |
next |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1318 |
case (2 T F) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1319 |
then have fTF: "finite T" "\<forall>T\<in>F. finite T" "finite F" and TF: "T \<notin> F" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1320 |
and H: "setsum f (\<Union> F) = setsum (setsum f) F" by (auto simp add: finite_insert) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1321 |
from fTF have fUF: "finite (\<Union>F)" by (auto intro: finite_Union) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1322 |
from "2.prems" TF fTF |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1323 |
show ?case |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1324 |
by (auto simp add: H[symmetric] intro: setsum_Un_zero[OF fTF(1) fUF, of f]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1325 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1326 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1327 |
|
15402 | 1328 |
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
|
1329 |
(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
|
1330 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1331 |
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
|
1332 |
apply (erule finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1333 |
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
|
1334 |
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
|
1335 |
done |
15402 | 1336 |
|
1337 |
lemma setsum_diff1: "finite A \<Longrightarrow> |
|
1338 |
(setsum f (A - {a}) :: ('a::ab_group_add)) = |
|
1339 |
(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
|
1340 |
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
|
1341 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1342 |
lemma setsum_diff1'[rule_format]: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1343 |
"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
|
1344 |
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
|
1345 |
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
|
1346 |
done |
15552
8ab8e425410b
added setsum_diff1' which holds in more general cases than setsum_diff1
obua
parents:
15543
diff
changeset
|
1347 |
|
31438 | 1348 |
lemma setsum_diff1_ring: assumes "finite A" "a \<in> A" |
1349 |
shows "setsum f (A - {a}) = setsum f A - (f a::'a::ring)" |
|
1350 |
unfolding setsum_diff1'[OF assms] by auto |
|
1351 |
||
15402 | 1352 |
(* By Jeremy Siek: *) |
1353 |
||
1354 |
lemma setsum_diff_nat: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1355 |
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
|
1356 |
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
|
1357 |
using assms |
19535 | 1358 |
proof induct |
15402 | 1359 |
show "setsum f (A - {}) = (setsum f A) - (setsum f {})" by simp |
1360 |
next |
|
1361 |
fix F x assume finF: "finite F" and xnotinF: "x \<notin> F" |
|
1362 |
and xFinA: "insert x F \<subseteq> A" |
|
1363 |
and IH: "F \<subseteq> A \<Longrightarrow> setsum f (A - F) = setsum f A - setsum f F" |
|
1364 |
from xnotinF xFinA have xinAF: "x \<in> (A - F)" by simp |
|
1365 |
from xinAF have A: "setsum f ((A - F) - {x}) = setsum f (A - F) - f x" |
|
1366 |
by (simp add: setsum_diff1_nat) |
|
1367 |
from xFinA have "F \<subseteq> A" by simp |
|
1368 |
with IH have "setsum f (A - F) = setsum f A - setsum f F" by simp |
|
1369 |
with A have B: "setsum f ((A - F) - {x}) = setsum f A - setsum f F - f x" |
|
1370 |
by simp |
|
1371 |
from xnotinF have "A - insert x F = (A - F) - {x}" by auto |
|
1372 |
with B have C: "setsum f (A - insert x F) = setsum f A - setsum f F - f x" |
|
1373 |
by simp |
|
1374 |
from finF xnotinF have "setsum f (insert x F) = setsum f F + f x" by simp |
|
1375 |
with C have "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" |
|
1376 |
by simp |
|
1377 |
thus "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" by simp |
|
1378 |
qed |
|
1379 |
||
1380 |
lemma setsum_diff: |
|
1381 |
assumes le: "finite A" "B \<subseteq> A" |
|
1382 |
shows "setsum f (A - B) = setsum f A - ((setsum f B)::('a::ab_group_add))" |
|
1383 |
proof - |
|
1384 |
from le have finiteB: "finite B" using finite_subset by auto |
|
1385 |
show ?thesis using finiteB le |
|
21575 | 1386 |
proof induct |
19535 | 1387 |
case empty |
1388 |
thus ?case by auto |
|
1389 |
next |
|
1390 |
case (insert x F) |
|
1391 |
thus ?case using le finiteB |
|
1392 |
by (simp add: Diff_insert[where a=x and B=F] setsum_diff1 insert_absorb) |
|
15402 | 1393 |
qed |
19535 | 1394 |
qed |
15402 | 1395 |
|
1396 |
lemma setsum_mono: |
|
1397 |
assumes le: "\<And>i. i\<in>K \<Longrightarrow> f (i::'a) \<le> ((g i)::('b::{comm_monoid_add, pordered_ab_semigroup_add}))" |
|
1398 |
shows "(\<Sum>i\<in>K. f i) \<le> (\<Sum>i\<in>K. g i)" |
|
1399 |
proof (cases "finite K") |
|
1400 |
case True |
|
1401 |
thus ?thesis using le |
|
19535 | 1402 |
proof induct |
15402 | 1403 |
case empty |
1404 |
thus ?case by simp |
|
1405 |
next |
|
1406 |
case insert |
|
19535 | 1407 |
thus ?case using add_mono by fastsimp |
15402 | 1408 |
qed |
1409 |
next |
|
1410 |
case False |
|
1411 |
thus ?thesis |
|
1412 |
by (simp add: setsum_def) |
|
1413 |
qed |
|
1414 |
||
15554 | 1415 |
lemma setsum_strict_mono: |
19535 | 1416 |
fixes f :: "'a \<Rightarrow> 'b::{pordered_cancel_ab_semigroup_add,comm_monoid_add}" |
1417 |
assumes "finite A" "A \<noteq> {}" |
|
1418 |
and "!!x. x:A \<Longrightarrow> f x < g x" |
|
1419 |
shows "setsum f A < setsum g A" |
|
1420 |
using prems |
|
15554 | 1421 |
proof (induct rule: finite_ne_induct) |
1422 |
case singleton thus ?case by simp |
|
1423 |
next |
|
1424 |
case insert thus ?case by (auto simp: add_strict_mono) |
|
1425 |
qed |
|
1426 |
||
15535 | 1427 |
lemma setsum_negf: |
19535 | 1428 |
"setsum (%x. - (f x)::'a::ab_group_add) A = - setsum f A" |
15535 | 1429 |
proof (cases "finite A") |
22262 | 1430 |
case True thus ?thesis by (induct set: finite) auto |
15535 | 1431 |
next |
1432 |
case False thus ?thesis by (simp add: setsum_def) |
|
1433 |
qed |
|
15402 | 1434 |
|
15535 | 1435 |
lemma setsum_subtractf: |
19535 | 1436 |
"setsum (%x. ((f x)::'a::ab_group_add) - g x) A = |
1437 |
setsum f A - setsum g A" |
|
15535 | 1438 |
proof (cases "finite A") |
1439 |
case True thus ?thesis by (simp add: diff_minus setsum_addf setsum_negf) |
|
1440 |
next |
|
1441 |
case False thus ?thesis by (simp add: setsum_def) |
|
1442 |
qed |
|
15402 | 1443 |
|
15535 | 1444 |
lemma setsum_nonneg: |
19535 | 1445 |
assumes nn: "\<forall>x\<in>A. (0::'a::{pordered_ab_semigroup_add,comm_monoid_add}) \<le> f x" |
1446 |
shows "0 \<le> setsum f A" |
|
15535 | 1447 |
proof (cases "finite A") |
1448 |
case True thus ?thesis using nn |
|
21575 | 1449 |
proof induct |
19535 | 1450 |
case empty then show ?case by simp |
1451 |
next |
|
1452 |
case (insert x F) |
|
1453 |
then have "0 + 0 \<le> f x + setsum f F" by (blast intro: add_mono) |
|
1454 |
with insert show ?case by simp |
|
1455 |
qed |
|
15535 | 1456 |
next |
1457 |
case False thus ?thesis by (simp add: setsum_def) |
|
1458 |
qed |
|
15402 | 1459 |
|
15535 | 1460 |
lemma setsum_nonpos: |
19535 | 1461 |
assumes np: "\<forall>x\<in>A. f x \<le> (0::'a::{pordered_ab_semigroup_add,comm_monoid_add})" |
1462 |
shows "setsum f A \<le> 0" |
|
15535 | 1463 |
proof (cases "finite A") |
1464 |
case True thus ?thesis using np |
|
21575 | 1465 |
proof induct |
19535 | 1466 |
case empty then show ?case by simp |
1467 |
next |
|
1468 |
case (insert x F) |
|
1469 |
then have "f x + setsum f F \<le> 0 + 0" by (blast intro: add_mono) |
|
1470 |
with insert show ?case by simp |
|
1471 |
qed |
|
15535 | 1472 |
next |
1473 |
case False thus ?thesis by (simp add: setsum_def) |
|
1474 |
qed |
|
15402 | 1475 |
|
15539 | 1476 |
lemma setsum_mono2: |
1477 |
fixes f :: "'a \<Rightarrow> 'b :: {pordered_ab_semigroup_add_imp_le,comm_monoid_add}" |
|
1478 |
assumes fin: "finite B" and sub: "A \<subseteq> B" and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b" |
|
1479 |
shows "setsum f A \<le> setsum f B" |
|
1480 |
proof - |
|
1481 |
have "setsum f A \<le> setsum f A + setsum f (B-A)" |
|
1482 |
by(simp add: add_increasing2[OF setsum_nonneg] nn Ball_def) |
|
1483 |
also have "\<dots> = setsum f (A \<union> (B-A))" using fin finite_subset[OF sub fin] |
|
1484 |
by (simp add:setsum_Un_disjoint del:Un_Diff_cancel) |
|
1485 |
also have "A \<union> (B-A) = B" using sub by blast |
|
1486 |
finally show ?thesis . |
|
1487 |
qed |
|
15542 | 1488 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1489 |
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
|
1490 |
ALL x: B - A. |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1491 |
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
|
1492 |
setsum f A <= setsum f B" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1493 |
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
|
1494 |
apply (erule ssubst) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1495 |
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
|
1496 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1497 |
apply (rule add_left_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1498 |
apply (erule setsum_nonneg) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1499 |
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
|
1500 |
apply (erule finite_subset, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1501 |
apply (rule finite_subset) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1502 |
prefer 2 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1503 |
apply assumption |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1504 |
apply auto |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1505 |
apply (rule setsum_cong) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1506 |
apply auto |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1507 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
1508 |
|
19279 | 1509 |
lemma setsum_right_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1510 |
fixes f :: "'a => ('b::semiring_0)" |
15402 | 1511 |
shows "r * setsum f A = setsum (%n. r * f n) A" |
1512 |
proof (cases "finite A") |
|
1513 |
case True |
|
1514 |
thus ?thesis |
|
21575 | 1515 |
proof induct |
15402 | 1516 |
case empty thus ?case by simp |
1517 |
next |
|
1518 |
case (insert x A) thus ?case by (simp add: right_distrib) |
|
1519 |
qed |
|
1520 |
next |
|
1521 |
case False thus ?thesis by (simp add: setsum_def) |
|
1522 |
qed |
|
1523 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1524 |
lemma setsum_left_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1525 |
"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
|
1526 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1527 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1528 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1529 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1530 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1531 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1532 |
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
|
1533 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1534 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1535 |
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
|
1536 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1537 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1538 |
lemma setsum_divide_distrib: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1539 |
"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
|
1540 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1541 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1542 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1543 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1544 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1545 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1546 |
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
|
1547 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1548 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1549 |
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
|
1550 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1551 |
|
15535 | 1552 |
lemma setsum_abs[iff]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1553 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15402 | 1554 |
shows "abs (setsum f A) \<le> setsum (%i. abs(f i)) A" |
15535 | 1555 |
proof (cases "finite A") |
1556 |
case True |
|
1557 |
thus ?thesis |
|
21575 | 1558 |
proof induct |
15535 | 1559 |
case empty thus ?case by simp |
1560 |
next |
|
1561 |
case (insert x A) |
|
1562 |
thus ?case by (auto intro: abs_triangle_ineq order_trans) |
|
1563 |
qed |
|
15402 | 1564 |
next |
15535 | 1565 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 1566 |
qed |
1567 |
||
15535 | 1568 |
lemma setsum_abs_ge_zero[iff]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1569 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15402 | 1570 |
shows "0 \<le> setsum (%i. abs(f i)) A" |
15535 | 1571 |
proof (cases "finite A") |
1572 |
case True |
|
1573 |
thus ?thesis |
|
21575 | 1574 |
proof induct |
15535 | 1575 |
case empty thus ?case by simp |
1576 |
next |
|
21733 | 1577 |
case (insert x A) thus ?case by (auto simp: add_nonneg_nonneg) |
15535 | 1578 |
qed |
15402 | 1579 |
next |
15535 | 1580 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 1581 |
qed |
1582 |
||
15539 | 1583 |
lemma abs_setsum_abs[simp]: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25205
diff
changeset
|
1584 |
fixes f :: "'a => ('b::pordered_ab_group_add_abs)" |
15539 | 1585 |
shows "abs (\<Sum>a\<in>A. abs(f a)) = (\<Sum>a\<in>A. abs(f a))" |
1586 |
proof (cases "finite A") |
|
1587 |
case True |
|
1588 |
thus ?thesis |
|
21575 | 1589 |
proof induct |
15539 | 1590 |
case empty thus ?case by simp |
1591 |
next |
|
1592 |
case (insert a A) |
|
1593 |
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 |
|
1594 |
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
|
1595 |
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
|
1596 |
by (simp del: abs_of_nonneg) |
15539 | 1597 |
also have "\<dots> = (\<Sum>a\<in>insert a A. \<bar>f a\<bar>)" using insert by simp |
1598 |
finally show ?case . |
|
1599 |
qed |
|
1600 |
next |
|
1601 |
case False thus ?thesis by (simp add: setsum_def) |
|
1602 |
qed |
|
1603 |
||
15402 | 1604 |
|
31080 | 1605 |
lemma setsum_Plus: |
1606 |
fixes A :: "'a set" and B :: "'b set" |
|
1607 |
assumes fin: "finite A" "finite B" |
|
1608 |
shows "setsum f (A <+> B) = setsum (f \<circ> Inl) A + setsum (f \<circ> Inr) B" |
|
1609 |
proof - |
|
1610 |
have "A <+> B = Inl ` A \<union> Inr ` B" by auto |
|
1611 |
moreover from fin have "finite (Inl ` A :: ('a + 'b) set)" "finite (Inr ` B :: ('a + 'b) set)" |
|
1612 |
by(auto intro: finite_imageI) |
|
1613 |
moreover have "Inl ` A \<inter> Inr ` B = ({} :: ('a + 'b) set)" by auto |
|
1614 |
moreover have "inj_on (Inl :: 'a \<Rightarrow> 'a + 'b) A" "inj_on (Inr :: 'b \<Rightarrow> 'a + 'b) B" by(auto intro: inj_onI) |
|
1615 |
ultimately show ?thesis using fin by(simp add: setsum_Un_disjoint setsum_reindex) |
|
1616 |
qed |
|
1617 |
||
1618 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1619 |
text {* Commuting outer and inner summation *} |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1620 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1621 |
lemma swap_inj_on: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1622 |
"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
|
1623 |
by (unfold inj_on_def) fast |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1624 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1625 |
lemma swap_product: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1626 |
"(%(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
|
1627 |
by (simp add: split_def image_def) blast |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1628 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1629 |
lemma setsum_commute: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1630 |
"(\<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
|
1631 |
proof (simp add: setsum_cartesian_product) |
17189 | 1632 |
have "(\<Sum>(x,y) \<in> A <*> B. f x y) = |
1633 |
(\<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
|
1634 |
(is "?s = _") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1635 |
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
|
1636 |
apply (simp add: split_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1637 |
done |
17189 | 1638 |
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
|
1639 |
(is "_ = ?t") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1640 |
apply (simp add: swap_product) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1641 |
done |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1642 |
finally show "?s = ?t" . |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1643 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1644 |
|
19279 | 1645 |
lemma setsum_product: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
1646 |
fixes f :: "'a => ('b::semiring_0)" |
19279 | 1647 |
shows "setsum f A * setsum g B = (\<Sum>i\<in>A. \<Sum>j\<in>B. f i * g j)" |
1648 |
by (simp add: setsum_right_distrib setsum_left_distrib) (rule setsum_commute) |
|
1649 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
1650 |
|
15402 | 1651 |
subsection {* Generalized product over a set *} |
1652 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1653 |
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
|
1654 |
where "setprod f A == if finite A then fold_image (op *) f 1 A else 1" |
15402 | 1655 |
|
19535 | 1656 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
1657 |
Setprod ("\<Prod>_" [1000] 999) where |
19535 | 1658 |
"\<Prod>A == setprod (%x. x) A" |
1659 |
||
15402 | 1660 |
syntax |
17189 | 1661 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3PROD _:_. _)" [0, 51, 10] 10) |
15402 | 1662 |
syntax (xsymbols) |
17189 | 1663 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 1664 |
syntax (HTML output) |
17189 | 1665 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
16550 | 1666 |
|
1667 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1668 |
"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
|
1669 |
"\<Prod>i\<in>A. b" == "CONST setprod (%i. b) A" |
16550 | 1670 |
|
1671 |
text{* Instead of @{term"\<Prod>x\<in>{x. P}. e"} we introduce the shorter |
|
1672 |
@{text"\<Prod>x|P. e"}. *} |
|
1673 |
||
1674 |
syntax |
|
17189 | 1675 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3PROD _ |/ _./ _)" [0,0,10] 10) |
16550 | 1676 |
syntax (xsymbols) |
17189 | 1677 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 1678 |
syntax (HTML output) |
17189 | 1679 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 1680 |
|
15402 | 1681 |
translations |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1682 |
"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
|
1683 |
"\<Prod>x|P. t" => "CONST setprod (%x. t) {x. P}" |
16550 | 1684 |
|
15402 | 1685 |
|
1686 |
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
|
1687 |
by (auto simp add: setprod_def) |
15402 | 1688 |
|
1689 |
lemma setprod_insert [simp]: "[| finite A; a \<notin> A |] ==> |
|
1690 |
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
|
1691 |
by (simp add: setprod_def) |
15402 | 1692 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1693 |
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
|
1694 |
by (simp add: setprod_def) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1695 |
|
15402 | 1696 |
lemma setprod_reindex: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1697 |
"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
|
1698 |
by(auto simp: setprod_def fold_image_reindex dest!:finite_imageD) |
15402 | 1699 |
|
1700 |
lemma setprod_reindex_id: "inj_on f B ==> setprod f B = setprod id (f ` B)" |
|
1701 |
by (auto simp add: setprod_reindex) |
|
1702 |
||
1703 |
lemma setprod_cong: |
|
1704 |
"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
|
1705 |
by(fastsimp simp: setprod_def intro: fold_image_cong) |
15402 | 1706 |
|
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1707 |
lemma strong_setprod_cong[cong]: |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
1708 |
"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
|
1709 |
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
|
1710 |
|
15402 | 1711 |
lemma setprod_reindex_cong: "inj_on f A ==> |
1712 |
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
|
1713 |
by (frule setprod_reindex, simp) |
15402 | 1714 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1715 |
lemma strong_setprod_reindex_cong: assumes i: "inj_on f A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1716 |
and B: "B = f ` A" and eq: "\<And>x. x \<in> A \<Longrightarrow> g x = (h \<circ> f) x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1717 |
shows "setprod h B = setprod g A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1718 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1719 |
have "setprod h B = setprod (h o f) A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1720 |
by (simp add: B setprod_reindex[OF i, of h]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1721 |
then show ?thesis apply simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1722 |
apply (rule setprod_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1723 |
apply simp |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1724 |
by (simp add: eq) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1725 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1726 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1727 |
lemma setprod_Un_one: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1728 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1729 |
and I0: "\<forall>x \<in> S\<inter>T. f x = 1" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1730 |
shows "setprod f (S \<union> T) = setprod f S * setprod f T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1731 |
using fS fT |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1732 |
apply (simp add: setprod_def) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1733 |
apply (rule fold_image_Un_one) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1734 |
using I0 by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
1735 |
|
15402 | 1736 |
|
1737 |
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
|
1738 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1739 |
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
|
1740 |
done |
15402 | 1741 |
|
1742 |
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
|
1743 |
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
|
1744 |
apply (erule ssubst, rule setprod_1) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1745 |
apply (rule setprod_cong, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1746 |
done |
15402 | 1747 |
|
1748 |
lemma setprod_Un_Int: "finite A ==> finite B |
|
1749 |
==> 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
|
1750 |
by(simp add: setprod_def fold_image_Un_Int[symmetric]) |
15402 | 1751 |
|
1752 |
lemma setprod_Un_disjoint: "finite A ==> finite B |
|
1753 |
==> A Int B = {} ==> setprod g (A Un B) = setprod g A * setprod g B" |
|
1754 |
by (subst setprod_Un_Int [symmetric], auto) |
|
1755 |
||
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1756 |
lemma setprod_mono_one_left: |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1757 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1758 |
and z: "\<forall>i \<in> T - S. f i = 1" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1759 |
shows "setprod f S = setprod f T" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1760 |
proof- |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1761 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1762 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1763 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1764 |
show ?thesis |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1765 |
by (simp add: setprod_Un_disjoint[OF f d, unfolded eq[symmetric]] setprod_1'[OF z]) |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1766 |
qed |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1767 |
|
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1768 |
lemmas setprod_mono_one_right = setprod_mono_one_left [THEN sym] |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
1769 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1770 |
lemma setprod_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1771 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1772 |
shows "setprod (\<lambda>k. if k=a then b k else 1) S = (if a \<in> S then b a else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1773 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1774 |
let ?f = "(\<lambda>k. if k=a then b k else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1775 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1776 |
hence "\<forall> k\<in> S. ?f k = 1" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1777 |
hence ?thesis using a by (simp add: setprod_1 cong add: setprod_cong) } |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1778 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1779 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1780 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1781 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1782 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1783 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1784 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1785 |
have fA1: "setprod ?f ?A = 1" apply (rule setprod_1') by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1786 |
have "setprod ?f ?A * setprod ?f ?B = setprod ?f S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1787 |
using setprod_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1788 |
by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1789 |
then have ?thesis using a by (simp add: fA1 cong add: setprod_cong cong del: if_weak_cong)} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1790 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1791 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1792 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1793 |
lemma setprod_delta': |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1794 |
assumes fS: "finite S" shows |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1795 |
"setprod (\<lambda>k. if a = k then b k else 1) S = |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1796 |
(if a\<in> S then b a else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1797 |
using setprod_delta[OF fS, of a b, symmetric] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1798 |
by (auto intro: setprod_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1799 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1800 |
|
15402 | 1801 |
lemma setprod_UN_disjoint: |
1802 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
|
1803 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==> |
|
1804 |
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
|
1805 |
by(simp add: setprod_def fold_image_UN_disjoint cong: setprod_cong) |
15402 | 1806 |
|
1807 |
lemma setprod_Union_disjoint: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1808 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1809 |
(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
|
1810 |
==> setprod f (Union C) = setprod (setprod f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1811 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1812 |
prefer 2 apply (force dest: finite_UnionD simp add: setprod_def) |
15402 | 1813 |
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
|
1814 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1815 |
done |
15402 | 1816 |
|
1817 |
lemma setprod_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
|
16550 | 1818 |
(\<Prod>x\<in>A. (\<Prod>y\<in> B x. f x y)) = |
17189 | 1819 |
(\<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
|
1820 |
by(simp add:setprod_def fold_image_Sigma split_def cong:setprod_cong) |
15402 | 1821 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1822 |
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
|
1823 |
lemma setprod_cartesian_product: |
17189 | 1824 |
"(\<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
|
1825 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1826 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1827 |
apply (simp add: setprod_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1828 |
apply (cases "A={}", simp) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1829 |
apply (simp add: setprod_1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1830 |
apply (auto simp add: setprod_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1831 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1832 |
done |
15402 | 1833 |
|
1834 |
lemma setprod_timesf: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1835 |
"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
|
1836 |
by(simp add:setprod_def fold_image_distrib) |
15402 | 1837 |
|
1838 |
||
1839 |
subsubsection {* Properties in more restricted classes of structures *} |
|
1840 |
||
1841 |
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
|
1842 |
"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
|
1843 |
by (induct set: finite) auto |
15402 | 1844 |
|
1845 |
lemma setprod_zero: |
|
23277 | 1846 |
"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
|
1847 |
apply (induct set: finite, force, clarsimp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1848 |
apply (erule disjE, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1849 |
done |
15402 | 1850 |
|
1851 |
lemma setprod_nonneg [rule_format]: |
|
30841
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1852 |
"(ALL x: A. (0::'a::ordered_semidom) \<le> f x) --> 0 \<le> setprod f A" |
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1853 |
by (cases "finite A", induct set: finite, simp_all add: mult_nonneg_nonneg) |
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1854 |
|
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1855 |
lemma setprod_pos [rule_format]: "(ALL x: A. (0::'a::ordered_semidom) < f x) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1856 |
--> 0 < setprod f A" |
30841
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1857 |
by (cases "finite A", induct set: finite, simp_all add: mult_pos_pos) |
15402 | 1858 |
|
30843 | 1859 |
lemma setprod_zero_iff[simp]: "finite A ==> |
1860 |
(setprod f A = (0::'a::{comm_semiring_1,no_zero_divisors})) = |
|
1861 |
(EX x: A. f x = 0)" |
|
1862 |
by (erule finite_induct, auto simp:no_zero_divisors) |
|
1863 |
||
1864 |
lemma setprod_pos_nat: |
|
1865 |
"finite S ==> (ALL x : S. f x > (0::nat)) ==> setprod f S > 0" |
|
1866 |
using setprod_zero_iff by(simp del:neq0_conv add:neq0_conv[symmetric]) |
|
15402 | 1867 |
|
30863 | 1868 |
lemma setprod_pos_nat_iff[simp]: |
1869 |
"finite S ==> (setprod f S > 0) = (ALL x : S. f x > (0::nat))" |
|
1870 |
using setprod_zero_iff by(simp del:neq0_conv add:neq0_conv[symmetric]) |
|
1871 |
||
15402 | 1872 |
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
|
1873 |
(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
|
1874 |
= setprod f A * setprod f B / setprod f (A Int B)" |
30843 | 1875 |
by (subst setprod_Un_Int [symmetric], auto) |
15402 | 1876 |
|
1877 |
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
|
1878 |
(setprod f (A - {a}) :: 'a :: {field}) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1879 |
(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
|
1880 |
by (erule finite_induct) (auto simp add: insert_Diff_if) |
15402 | 1881 |
|
1882 |
lemma setprod_inversef: "finite A ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1883 |
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
|
1884 |
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
|
1885 |
by (erule finite_induct) auto |
15402 | 1886 |
|
1887 |
lemma setprod_dividef: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1888 |
"[|finite A; |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1889 |
\<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
|
1890 |
==> 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
|
1891 |
apply (subgoal_tac |
15402 | 1892 |
"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
|
1893 |
apply (erule ssubst) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1894 |
apply (subst divide_inverse) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1895 |
apply (subst setprod_timesf) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1896 |
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
|
1897 |
apply (rule setprod_cong, rule refl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1898 |
apply (subst divide_inverse, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1899 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1900 |
|
29925 | 1901 |
lemma setprod_dvd_setprod [rule_format]: |
1902 |
"(ALL x : A. f x dvd g x) \<longrightarrow> setprod f A dvd setprod g A" |
|
1903 |
apply (cases "finite A") |
|
1904 |
apply (induct set: finite) |
|
1905 |
apply (auto simp add: dvd_def) |
|
1906 |
apply (rule_tac x = "k * ka" in exI) |
|
1907 |
apply (simp add: algebra_simps) |
|
1908 |
done |
|
1909 |
||
1910 |
lemma setprod_dvd_setprod_subset: |
|
1911 |
"finite B \<Longrightarrow> A <= B \<Longrightarrow> setprod f A dvd setprod f B" |
|
1912 |
apply (subgoal_tac "setprod f B = setprod f A * setprod f (B - A)") |
|
1913 |
apply (unfold dvd_def, blast) |
|
1914 |
apply (subst setprod_Un_disjoint [symmetric]) |
|
1915 |
apply (auto elim: finite_subset intro: setprod_cong) |
|
1916 |
done |
|
1917 |
||
1918 |
lemma setprod_dvd_setprod_subset2: |
|
1919 |
"finite B \<Longrightarrow> A <= B \<Longrightarrow> ALL x : A. (f x::'a::comm_semiring_1) dvd g x \<Longrightarrow> |
|
1920 |
setprod f A dvd setprod g B" |
|
1921 |
apply (rule dvd_trans) |
|
1922 |
apply (rule setprod_dvd_setprod, erule (1) bspec) |
|
1923 |
apply (erule (1) setprod_dvd_setprod_subset) |
|
1924 |
done |
|
1925 |
||
1926 |
lemma dvd_setprod: "finite A \<Longrightarrow> i:A \<Longrightarrow> |
|
1927 |
(f i ::'a::comm_semiring_1) dvd setprod f A" |
|
1928 |
by (induct set: finite) (auto intro: dvd_mult) |
|
1929 |
||
1930 |
lemma dvd_setsum [rule_format]: "(ALL i : A. d dvd f i) \<longrightarrow> |
|
1931 |
(d::'a::comm_semiring_1) dvd (SUM x : A. f x)" |
|
1932 |
apply (cases "finite A") |
|
1933 |
apply (induct set: finite) |
|
1934 |
apply auto |
|
1935 |
done |
|
1936 |
||
15402 | 1937 |
|
12396 | 1938 |
subsection {* Finite cardinality *} |
1939 |
||
15402 | 1940 |
text {* This definition, although traditional, is ugly to work with: |
1941 |
@{text "card A == LEAST n. EX f. A = {f i | i. i < n}"}. |
|
1942 |
But now that we have @{text setsum} things are easy: |
|
12396 | 1943 |
*} |
1944 |
||
31380 | 1945 |
definition card :: "'a set \<Rightarrow> nat" where |
1946 |
"card A = setsum (\<lambda>x. 1) A" |
|
1947 |
||
1948 |
lemmas card_eq_setsum = card_def |
|
12396 | 1949 |
|
1950 |
lemma card_empty [simp]: "card {} = 0" |
|
31380 | 1951 |
by (simp add: card_def) |
12396 | 1952 |
|
1953 |
lemma card_insert_disjoint [simp]: |
|
1954 |
"finite A ==> x \<notin> A ==> card (insert x A) = Suc(card A)" |
|
31380 | 1955 |
by (simp add: card_def) |
15402 | 1956 |
|
1957 |
lemma card_insert_if: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1958 |
"finite A ==> card (insert x A) = (if x:A then card A else Suc(card(A)))" |
31380 | 1959 |
by (simp add: insert_absorb) |
1960 |
||
1961 |
lemma card_infinite [simp]: "~ finite A ==> card A = 0" |
|
1962 |
by (simp add: card_def) |
|
1963 |
||
1964 |
lemma card_ge_0_finite: |
|
1965 |
"card A > 0 \<Longrightarrow> finite A" |
|
1966 |
by (rule ccontr) simp |
|
12396 | 1967 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
1968 |
lemma card_0_eq [simp,noatp]: "finite A ==> (card A = 0) = (A = {})" |
31380 | 1969 |
apply auto |
1970 |
apply (drule_tac a = x in mk_disjoint_insert, clarify, auto) |
|
1971 |
done |
|
1972 |
||
1973 |
lemma finite_UNIV_card_ge_0: |
|
1974 |
"finite (UNIV :: 'a set) \<Longrightarrow> card (UNIV :: 'a set) > 0" |
|
1975 |
by (rule ccontr) simp |
|
12396 | 1976 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1977 |
lemma card_eq_0_iff: "(card A = 0) = (A = {} | ~ finite A)" |
31380 | 1978 |
by auto |
24853 | 1979 |
|
12396 | 1980 |
lemma card_Suc_Diff1: "finite A ==> x: A ==> Suc (card (A - {x})) = card A" |
14302 | 1981 |
apply(rule_tac t = A in insert_Diff [THEN subst], assumption) |
1982 |
apply(simp del:insert_Diff_single) |
|
1983 |
done |
|
12396 | 1984 |
|
1985 |
lemma card_Diff_singleton: |
|
24853 | 1986 |
"finite A ==> x: A ==> card (A - {x}) = card A - 1" |
1987 |
by (simp add: card_Suc_Diff1 [symmetric]) |
|
12396 | 1988 |
|
1989 |
lemma card_Diff_singleton_if: |
|
24853 | 1990 |
"finite A ==> card (A-{x}) = (if x : A then card A - 1 else card A)" |
1991 |
by (simp add: card_Diff_singleton) |
|
1992 |
||
1993 |
lemma card_Diff_insert[simp]: |
|
1994 |
assumes "finite A" and "a:A" and "a ~: B" |
|
1995 |
shows "card(A - insert a B) = card(A - B) - 1" |
|
1996 |
proof - |
|
1997 |
have "A - insert a B = (A - B) - {a}" using assms by blast |
|
1998 |
then show ?thesis using assms by(simp add:card_Diff_singleton) |
|
1999 |
qed |
|
12396 | 2000 |
|
2001 |
lemma card_insert: "finite A ==> card (insert x A) = Suc (card (A - {x}))" |
|
24853 | 2002 |
by (simp add: card_insert_if card_Suc_Diff1 del:card_Diff_insert) |
12396 | 2003 |
|
2004 |
lemma card_insert_le: "finite A ==> card A <= card (insert x A)" |
|
24853 | 2005 |
by (simp add: card_insert_if) |
12396 | 2006 |
|
15402 | 2007 |
lemma card_mono: "\<lbrakk> finite B; A \<subseteq> B \<rbrakk> \<Longrightarrow> card A \<le> card B" |
15539 | 2008 |
by (simp add: card_def setsum_mono2) |
15402 | 2009 |
|
12396 | 2010 |
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
|
2011 |
apply (induct set: finite, simp, clarify) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2012 |
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
|
2013 |
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
|
2014 |
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
|
2015 |
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
|
2016 |
apply (case_tac "card A", auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2017 |
done |
12396 | 2018 |
|
2019 |
lemma psubset_card_mono: "finite B ==> A < B ==> card A < card B" |
|
26792 | 2020 |
apply (simp add: psubset_eq linorder_not_le [symmetric]) |
24853 | 2021 |
apply (blast dest: card_seteq) |
2022 |
done |
|
12396 | 2023 |
|
2024 |
lemma card_Un_Int: "finite A ==> finite B |
|
2025 |
==> card A + card B = card (A Un B) + card (A Int B)" |
|
15402 | 2026 |
by(simp add:card_def setsum_Un_Int) |
12396 | 2027 |
|
2028 |
lemma card_Un_disjoint: "finite A ==> finite B |
|
2029 |
==> A Int B = {} ==> card (A Un B) = card A + card B" |
|
24853 | 2030 |
by (simp add: card_Un_Int) |
12396 | 2031 |
|
2032 |
lemma card_Diff_subset: |
|
15402 | 2033 |
"finite B ==> B <= A ==> card (A - B) = card A - card B" |
2034 |
by(simp add:card_def setsum_diff_nat) |
|
12396 | 2035 |
|
2036 |
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
|
2037 |
apply (rule Suc_less_SucD) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2038 |
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
|
2039 |
done |
12396 | 2040 |
|
2041 |
lemma card_Diff2_less: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2042 |
"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
|
2043 |
apply (case_tac "x = y") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2044 |
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
|
2045 |
apply (rule less_trans) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2046 |
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
|
2047 |
done |
12396 | 2048 |
|
2049 |
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
|
2050 |
apply (case_tac "x : A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2051 |
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
|
2052 |
done |
12396 | 2053 |
|
2054 |
lemma card_psubset: "finite B ==> A \<subseteq> B ==> card A < card B ==> A < B" |
|
14208 | 2055 |
by (erule psubsetI, blast) |
12396 | 2056 |
|
14889 | 2057 |
lemma insert_partition: |
15402 | 2058 |
"\<lbrakk> x \<notin> F; \<forall>c1 \<in> insert x F. \<forall>c2 \<in> insert x F. c1 \<noteq> c2 \<longrightarrow> c1 \<inter> c2 = {} \<rbrakk> |
2059 |
\<Longrightarrow> x \<inter> \<Union> F = {}" |
|
14889 | 2060 |
by auto |
2061 |
||
19793 | 2062 |
text{* main cardinality theorem *} |
14889 | 2063 |
lemma card_partition [rule_format]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2064 |
"finite C ==> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2065 |
finite (\<Union> C) --> |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2066 |
(\<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
|
2067 |
(\<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
|
2068 |
k * card(C) = card (\<Union> C)" |
14889 | 2069 |
apply (erule finite_induct, simp) |
2070 |
apply (simp add: card_insert_disjoint card_Un_disjoint insert_partition |
|
2071 |
finite_subset [of _ "\<Union> (insert x F)"]) |
|
2072 |
done |
|
2073 |
||
31380 | 2074 |
lemma card_eq_UNIV_imp_eq_UNIV: |
2075 |
assumes fin: "finite (UNIV :: 'a set)" |
|
2076 |
and card: "card A = card (UNIV :: 'a set)" |
|
2077 |
shows "A = (UNIV :: 'a set)" |
|
2078 |
proof |
|
2079 |
show "A \<subseteq> UNIV" by simp |
|
2080 |
show "UNIV \<subseteq> A" |
|
2081 |
proof |
|
2082 |
fix x |
|
2083 |
show "x \<in> A" |
|
2084 |
proof (rule ccontr) |
|
2085 |
assume "x \<notin> A" |
|
2086 |
then have "A \<subset> UNIV" by auto |
|
2087 |
with fin have "card A < card (UNIV :: 'a set)" by (fact psubset_card_mono) |
|
2088 |
with card show False by simp |
|
2089 |
qed |
|
2090 |
qed |
|
2091 |
qed |
|
12396 | 2092 |
|
19793 | 2093 |
text{*The form of a finite set of given cardinality*} |
2094 |
||
2095 |
lemma card_eq_SucD: |
|
24853 | 2096 |
assumes "card A = Suc k" |
2097 |
shows "\<exists>b B. A = insert b B & b \<notin> B & card B = k & (k=0 \<longrightarrow> B={})" |
|
19793 | 2098 |
proof - |
24853 | 2099 |
have fin: "finite A" using assms by (auto intro: ccontr) |
2100 |
moreover have "card A \<noteq> 0" using assms by auto |
|
2101 |
ultimately obtain b where b: "b \<in> A" by auto |
|
19793 | 2102 |
show ?thesis |
2103 |
proof (intro exI conjI) |
|
2104 |
show "A = insert b (A-{b})" using b by blast |
|
2105 |
show "b \<notin> A - {b}" by blast |
|
24853 | 2106 |
show "card (A - {b}) = k" and "k = 0 \<longrightarrow> A - {b} = {}" |
2107 |
using assms b fin by(fastsimp dest:mk_disjoint_insert)+ |
|
19793 | 2108 |
qed |
2109 |
qed |
|
2110 |
||
2111 |
lemma card_Suc_eq: |
|
24853 | 2112 |
"(card A = Suc k) = |
2113 |
(\<exists>b B. A = insert b B & b \<notin> B & card B = k & (k=0 \<longrightarrow> B={}))" |
|
2114 |
apply(rule iffI) |
|
2115 |
apply(erule card_eq_SucD) |
|
2116 |
apply(auto) |
|
2117 |
apply(subst card_insert) |
|
2118 |
apply(auto intro:ccontr) |
|
2119 |
done |
|
19793 | 2120 |
|
31380 | 2121 |
lemma finite_fun_UNIVD2: |
2122 |
assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)" |
|
2123 |
shows "finite (UNIV :: 'b set)" |
|
2124 |
proof - |
|
2125 |
from fin have "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary))" |
|
2126 |
by(rule finite_imageI) |
|
2127 |
moreover have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary)" |
|
2128 |
by(rule UNIV_eq_I) auto |
|
2129 |
ultimately show "finite (UNIV :: 'b set)" by simp |
|
2130 |
qed |
|
2131 |
||
15539 | 2132 |
lemma setsum_constant [simp]: "(\<Sum>x \<in> A. y) = of_nat(card A) * y" |
2133 |
apply (cases "finite A") |
|
2134 |
apply (erule finite_induct) |
|
29667 | 2135 |
apply (auto simp add: algebra_simps) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2136 |
done |
15402 | 2137 |
|
31017 | 2138 |
lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::{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
|
2139 |
apply (erule finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2140 |
apply (auto simp add: power_Suc) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2141 |
done |
15402 | 2142 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2143 |
lemma setprod_gen_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2144 |
assumes fS: "finite S" |
31017 | 2145 |
shows "setprod (\<lambda>k. if k=a then b k else c) S = (if a \<in> S then (b a ::'a::{comm_monoid_mult}) * c^ (card S - 1) else c^ card S)" |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2146 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2147 |
let ?f = "(\<lambda>k. if k=a then b k else c)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2148 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2149 |
hence "\<forall> k\<in> S. ?f k = c" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2150 |
hence ?thesis using a setprod_constant[OF fS, of c] by (simp add: setprod_1 cong add: setprod_cong) } |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2151 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2152 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2153 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2154 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2155 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2156 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2157 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2158 |
have fA0:"setprod ?f ?A = setprod (\<lambda>i. c) ?A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2159 |
apply (rule setprod_cong) by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2160 |
have cA: "card ?A = card S - 1" using fS a by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2161 |
have fA1: "setprod ?f ?A = c ^ card ?A" unfolding fA0 apply (rule setprod_constant) using fS by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2162 |
have "setprod ?f ?A * setprod ?f ?B = setprod ?f S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2163 |
using setprod_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2164 |
by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2165 |
then have ?thesis using a cA |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2166 |
by (simp add: fA1 ring_simps cong add: setprod_cong cong del: if_weak_cong)} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2167 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2168 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2169 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
2170 |
|
15542 | 2171 |
lemma setsum_bounded: |
23277 | 2172 |
assumes le: "\<And>i. i\<in>A \<Longrightarrow> f i \<le> (K::'a::{semiring_1, pordered_ab_semigroup_add})" |
15542 | 2173 |
shows "setsum f A \<le> of_nat(card A) * K" |
2174 |
proof (cases "finite A") |
|
2175 |
case True |
|
2176 |
thus ?thesis using le setsum_mono[where K=A and g = "%x. K"] by simp |
|
2177 |
next |
|
2178 |
case False thus ?thesis by (simp add: setsum_def) |
|
2179 |
qed |
|
2180 |
||
15402 | 2181 |
|
31080 | 2182 |
lemma card_UNIV_unit: "card (UNIV :: unit set) = 1" |
2183 |
unfolding UNIV_unit by simp |
|
2184 |
||
2185 |
||
15402 | 2186 |
subsubsection {* Cardinality of unions *} |
2187 |
||
2188 |
lemma card_UN_disjoint: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2189 |
"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
|
2190 |
(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
|
2191 |
==> 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
|
2192 |
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
|
2193 |
apply (subgoal_tac |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2194 |
"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
|
2195 |
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
|
2196 |
apply (simp cong: setsum_cong) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2197 |
done |
15402 | 2198 |
|
2199 |
lemma card_Union_disjoint: |
|
2200 |
"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
|
2201 |
(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
|
2202 |
==> card (Union C) = setsum card C" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2203 |
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
|
2204 |
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
|
2205 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2206 |
|
15402 | 2207 |
|
12396 | 2208 |
subsubsection {* Cardinality of image *} |
2209 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2210 |
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
|
2211 |
lemma image_eq_fold_image: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2212 |
"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
|
2213 |
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
|
2214 |
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
|
2215 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2216 |
interpret ab_semigroup_mult "op Un" |
28823 | 2217 |
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
|
2218 |
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
|
2219 |
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
|
2220 |
qed |
15447 | 2221 |
|
12396 | 2222 |
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
|
2223 |
apply (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2224 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2225 |
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
|
2226 |
done |
12396 | 2227 |
|
15402 | 2228 |
lemma card_image: "inj_on f A ==> card (f ` A) = card A" |
15539 | 2229 |
by(simp add:card_def setsum_reindex o_def del:setsum_constant) |
12396 | 2230 |
|
31451 | 2231 |
lemma bij_betw_same_card: "bij_betw f A B \<Longrightarrow> card A = card B" |
2232 |
by(auto simp: card_image bij_betw_def) |
|
2233 |
||
12396 | 2234 |
lemma endo_inj_surj: "finite A ==> f ` A \<subseteq> A ==> inj_on f A ==> f ` A = A" |
25162 | 2235 |
by (simp add: card_seteq card_image) |
12396 | 2236 |
|
15111 | 2237 |
lemma eq_card_imp_inj_on: |
2238 |
"[| finite A; card(f ` A) = card A |] ==> inj_on f A" |
|
21575 | 2239 |
apply (induct rule:finite_induct) |
2240 |
apply simp |
|
15111 | 2241 |
apply(frule card_image_le[where f = f]) |
2242 |
apply(simp add:card_insert_if split:if_splits) |
|
2243 |
done |
|
2244 |
||
2245 |
lemma inj_on_iff_eq_card: |
|
2246 |
"finite A ==> inj_on f A = (card(f ` A) = card A)" |
|
2247 |
by(blast intro: card_image eq_card_imp_inj_on) |
|
2248 |
||
12396 | 2249 |
|
15402 | 2250 |
lemma card_inj_on_le: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2251 |
"[|inj_on f A; f ` A \<subseteq> B; finite B |] ==> card A \<le> card B" |
15402 | 2252 |
apply (subgoal_tac "finite A") |
2253 |
apply (force intro: card_mono simp add: card_image [symmetric]) |
|
2254 |
apply (blast intro: finite_imageD dest: finite_subset) |
|
2255 |
done |
|
2256 |
||
2257 |
lemma card_bij_eq: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2258 |
"[|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
|
2259 |
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
|
2260 |
by (auto intro: le_anti_sym card_inj_on_le) |
15402 | 2261 |
|
2262 |
||
2263 |
subsubsection {* Cardinality of products *} |
|
2264 |
||
2265 |
(* |
|
2266 |
lemma SigmaI_insert: "y \<notin> A ==> |
|
2267 |
(SIGMA x:(insert y A). B x) = (({y} <*> (B y)) \<union> (SIGMA x: A. B x))" |
|
2268 |
by auto |
|
2269 |
*) |
|
2270 |
||
2271 |
lemma card_SigmaI [simp]: |
|
2272 |
"\<lbrakk> finite A; ALL a:A. finite (B a) \<rbrakk> |
|
2273 |
\<Longrightarrow> card (SIGMA x: A. B x) = (\<Sum>a\<in>A. card (B a))" |
|
15539 | 2274 |
by(simp add:card_def setsum_Sigma del:setsum_constant) |
15402 | 2275 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2276 |
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
|
2277 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2278 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2279 |
apply (auto simp add: card_eq_0_iff |
15539 | 2280 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2281 |
done |
15402 | 2282 |
|
2283 |
lemma card_cartesian_product_singleton: "card({x} <*> A) = card(A)" |
|
15539 | 2284 |
by (simp add: card_cartesian_product) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
2285 |
|
15402 | 2286 |
|
29025
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2287 |
subsubsection {* Cardinality of sums *} |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2288 |
|
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2289 |
lemma card_Plus: |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2290 |
assumes "finite A" and "finite B" |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2291 |
shows "card (A <+> B) = card A + card B" |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2292 |
proof - |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2293 |
have "Inl`A \<inter> Inr`B = {}" by fast |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2294 |
with assms show ?thesis |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2295 |
unfolding Plus_def |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2296 |
by (simp add: card_Un_disjoint card_image) |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2297 |
qed |
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28853
diff
changeset
|
2298 |
|
31080 | 2299 |
lemma card_Plus_conv_if: |
2300 |
"card (A <+> B) = (if finite A \<and> finite B then card(A) + card(B) else 0)" |
|
2301 |
by(auto simp: card_def setsum_Plus simp del: setsum_constant) |
|
2302 |
||
15402 | 2303 |
|
12396 | 2304 |
subsubsection {* Cardinality of the Powerset *} |
2305 |
||
2306 |
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
|
2307 |
apply (induct set: finite) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2308 |
apply (simp_all add: Pow_insert) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2309 |
apply (subst card_Un_disjoint, blast) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2310 |
apply (blast intro: finite_imageI, blast) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2311 |
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
|
2312 |
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
|
2313 |
apply (unfold inj_on_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2314 |
apply (blast elim!: equalityE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2315 |
done |
12396 | 2316 |
|
24342 | 2317 |
text {* Relates to equivalence classes. Based on a theorem of F. Kammüller. *} |
12396 | 2318 |
|
2319 |
lemma dvd_partition: |
|
15392 | 2320 |
"finite (Union C) ==> |
12396 | 2321 |
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
|
2322 |
(ALL c1: C. ALL c2: C. c1 \<noteq> c2 --> c1 Int c2 = {}) ==> |
12396 | 2323 |
k dvd card (Union C)" |
15392 | 2324 |
apply(frule finite_UnionD) |
2325 |
apply(rotate_tac -1) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2326 |
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
|
2327 |
apply (subst card_Un_disjoint) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2328 |
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
|
2329 |
done |
12396 | 2330 |
|
2331 |
||
25162 | 2332 |
subsubsection {* Relating injectivity and surjectivity *} |
2333 |
||
2334 |
lemma finite_surj_inj: "finite(A) \<Longrightarrow> A <= f`A \<Longrightarrow> inj_on f A" |
|
2335 |
apply(rule eq_card_imp_inj_on, assumption) |
|
2336 |
apply(frule finite_imageI) |
|
2337 |
apply(drule (1) card_seteq) |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2338 |
apply(erule card_image_le) |
25162 | 2339 |
apply simp |
2340 |
done |
|
2341 |
||
2342 |
lemma finite_UNIV_surj_inj: fixes f :: "'a \<Rightarrow> 'a" |
|
2343 |
shows "finite(UNIV:: 'a set) \<Longrightarrow> surj f \<Longrightarrow> inj f" |
|
2344 |
by (blast intro: finite_surj_inj subset_UNIV dest:surj_range) |
|
2345 |
||
2346 |
lemma finite_UNIV_inj_surj: fixes f :: "'a \<Rightarrow> 'a" |
|
2347 |
shows "finite(UNIV:: 'a set) \<Longrightarrow> inj f \<Longrightarrow> surj f" |
|
2348 |
by(fastsimp simp:surj_def dest!: endo_inj_surj) |
|
2349 |
||
2350 |
corollary infinite_UNIV_nat: "~finite(UNIV::nat set)" |
|
2351 |
proof |
|
2352 |
assume "finite(UNIV::nat set)" |
|
2353 |
with finite_UNIV_inj_surj[of Suc] |
|
2354 |
show False by simp (blast dest: Suc_neq_Zero surjD) |
|
2355 |
qed |
|
2356 |
||
29879 | 2357 |
lemma infinite_UNIV_char_0: |
2358 |
"\<not> finite (UNIV::'a::semiring_char_0 set)" |
|
2359 |
proof |
|
2360 |
assume "finite (UNIV::'a set)" |
|
2361 |
with subset_UNIV have "finite (range of_nat::'a set)" |
|
2362 |
by (rule finite_subset) |
|
2363 |
moreover have "inj (of_nat::nat \<Rightarrow> 'a)" |
|
2364 |
by (simp add: inj_on_def) |
|
2365 |
ultimately have "finite (UNIV::nat set)" |
|
2366 |
by (rule finite_imageD) |
|
2367 |
then show "False" |
|
2368 |
by (simp add: infinite_UNIV_nat) |
|
2369 |
qed |
|
25162 | 2370 |
|
15392 | 2371 |
subsection{* A fold functional for non-empty sets *} |
2372 |
||
2373 |
text{* Does not require start value. *} |
|
12396 | 2374 |
|
23736 | 2375 |
inductive |
22262 | 2376 |
fold1Set :: "('a => 'a => 'a) => 'a set => 'a => bool" |
2377 |
for f :: "'a => 'a => 'a" |
|
2378 |
where |
|
15506 | 2379 |
fold1Set_insertI [intro]: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2380 |
"\<lbrakk> fold_graph f a A x; a \<notin> A \<rbrakk> \<Longrightarrow> fold1Set f (insert a A) x" |
12396 | 2381 |
|
15392 | 2382 |
constdefs |
2383 |
fold1 :: "('a => 'a => 'a) => 'a set => 'a" |
|
22262 | 2384 |
"fold1 f A == THE x. fold1Set f A x" |
15506 | 2385 |
|
2386 |
lemma fold1Set_nonempty: |
|
22917 | 2387 |
"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
|
2388 |
by(erule fold1Set.cases, simp_all) |
15392 | 2389 |
|
23736 | 2390 |
inductive_cases empty_fold1SetE [elim!]: "fold1Set f {} x" |
2391 |
||
2392 |
inductive_cases insert_fold1SetE [elim!]: "fold1Set f (insert a X) x" |
|
22262 | 2393 |
|
2394 |
||
2395 |
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
|
2396 |
by (blast intro: fold_graph.intros elim: fold_graph.cases) |
15392 | 2397 |
|
22917 | 2398 |
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
|
2399 |
by (unfold fold1_def) blast |
12396 | 2400 |
|
15508 | 2401 |
lemma finite_nonempty_imp_fold1Set: |
22262 | 2402 |
"\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> EX x. fold1Set f A x" |
15508 | 2403 |
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
|
2404 |
apply (auto dest: finite_imp_fold_graph [of _ f]) |
15508 | 2405 |
done |
15506 | 2406 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2407 |
text{*First, some lemmas about @{const fold_graph}.*} |
15392 | 2408 |
|
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
|
2409 |
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
|
2410 |
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
|
2411 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2412 |
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
|
2413 |
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
|
2414 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2415 |
lemma fold_graph_insert_swap: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2416 |
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
|
2417 |
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
|
2418 |
proof - |
29223 | 2419 |
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
|
2420 |
from assms show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2421 |
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
|
2422 |
case emptyI thus ?case by (force simp add: fold_insert_aux mult_commute) |
15508 | 2423 |
next |
22262 | 2424 |
case (insertI x A y) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2425 |
have "fold_graph times z (insert x (insert b A)) (x * (z * y))" |
15521 | 2426 |
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
|
2427 |
thus ?case by (simp add: insert_commute mult_ac) |
15508 | 2428 |
qed |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2429 |
qed |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2430 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2431 |
lemma fold_graph_permute_diff: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2432 |
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
|
2433 |
shows "!!a. \<lbrakk>a \<in> A; b \<notin> A\<rbrakk> \<Longrightarrow> fold_graph times a (insert b (A-{a})) x" |
15508 | 2434 |
using fold |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2435 |
proof (induct rule: fold_graph.induct) |
15508 | 2436 |
case emptyI thus ?case by simp |
2437 |
next |
|
22262 | 2438 |
case (insertI x A y) |
15521 | 2439 |
have "a = x \<or> a \<in> A" using insertI by simp |
2440 |
thus ?case |
|
2441 |
proof |
|
2442 |
assume "a = x" |
|
2443 |
with insertI show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2444 |
by (simp add: id_def [symmetric], blast intro: fold_graph_insert_swap) |
15521 | 2445 |
next |
2446 |
assume ainA: "a \<in> A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2447 |
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
|
2448 |
using insertI by force |
15521 | 2449 |
moreover |
2450 |
have "insert x (insert b (A - {a})) = insert b (insert x A - {a})" |
|
2451 |
using ainA insertI by blast |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2452 |
ultimately show ?thesis by simp |
15508 | 2453 |
qed |
2454 |
qed |
|
2455 |
||
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
|
2456 |
lemma fold1_eq_fold: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2457 |
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
|
2458 |
proof - |
29223 | 2459 |
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
|
2460 |
from assms show ?thesis |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2461 |
apply (simp add: fold1_def fold_def) |
15508 | 2462 |
apply (rule the_equality) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2463 |
apply (best intro: fold_graph_determ theI dest: finite_imp_fold_graph [of _ times]) |
15508 | 2464 |
apply (rule sym, clarify) |
2465 |
apply (case_tac "Aa=A") |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2466 |
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
|
2467 |
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
|
2468 |
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
|
2469 |
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
|
2470 |
prefer 2 apply (blast elim: equalityE) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2471 |
apply (auto dest: fold_graph_permute_diff [where a=a]) |
15508 | 2472 |
done |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2473 |
qed |
15508 | 2474 |
|
15521 | 2475 |
lemma nonempty_iff: "(A \<noteq> {}) = (\<exists>x B. A = insert x B & x \<notin> B)" |
2476 |
apply safe |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2477 |
apply simp |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2478 |
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
|
2479 |
apply (drule_tac x="A-{x}" in spec, auto) |
15508 | 2480 |
done |
2481 |
||
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
|
2482 |
lemma fold1_insert: |
15521 | 2483 |
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
|
2484 |
shows "fold1 times (insert x A) = x * fold1 times A" |
15521 | 2485 |
proof - |
29223 | 2486 |
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
|
2487 |
from nonempty obtain a A' where "A = insert a A' & a ~: A'" |
15521 | 2488 |
by (auto simp add: nonempty_iff) |
2489 |
with A show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2490 |
by (simp add: insert_commute [of x] fold1_eq_fold eq_commute) |
15521 | 2491 |
qed |
2492 |
||
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
|
2493 |
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
|
2494 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
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
|
2496 |
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
|
2497 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2498 |
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
|
2499 |
apply unfold_locales |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2500 |
apply (simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2501 |
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
|
2502 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2503 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2504 |
|
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
|
2505 |
lemma fold1_insert_idem [simp]: |
15521 | 2506 |
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
|
2507 |
shows "fold1 times (insert x A) = x * fold1 times A" |
15521 | 2508 |
proof - |
29223 | 2509 |
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
|
2510 |
by (rule fun_left_comm_idem) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2511 |
from nonempty obtain a A' where A': "A = insert a A' & a ~: A'" |
15521 | 2512 |
by (auto simp add: nonempty_iff) |
2513 |
show ?thesis |
|
2514 |
proof cases |
|
2515 |
assume "a = x" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2516 |
thus ?thesis |
15521 | 2517 |
proof cases |
2518 |
assume "A' = {}" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2519 |
with prems show ?thesis by (simp add: mult_idem) |
15521 | 2520 |
next |
2521 |
assume "A' \<noteq> {}" |
|
2522 |
with prems show ?thesis |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2523 |
by (simp add: fold1_insert mult_assoc [symmetric] mult_idem) |
15521 | 2524 |
qed |
2525 |
next |
|
2526 |
assume "a \<noteq> x" |
|
2527 |
with prems show ?thesis |
|
2528 |
by (simp add: insert_commute fold1_eq_fold fold_insert_idem) |
|
2529 |
qed |
|
2530 |
qed |
|
15506 | 2531 |
|
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 |
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
|
2533 |
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
|
2534 |
and N: "finite N" "N \<noteq> {}" shows "h (fold1 times N) = fold1 times (h ` N)" |
22917 | 2535 |
using N proof (induct rule: finite_ne_induct) |
2536 |
case singleton thus ?case by simp |
|
2537 |
next |
|
2538 |
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
|
2539 |
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
|
2540 |
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
|
2541 |
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
|
2542 |
also have "times (h n) \<dots> = fold1 times (insert (h n) (h ` N))" |
22917 | 2543 |
using insert by(simp) |
2544 |
also have "insert (h n) (h ` N) = h ` insert n N" by simp |
|
2545 |
finally show ?case . |
|
2546 |
qed |
|
2547 |
||
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
|
2548 |
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
|
2549 |
|
15506 | 2550 |
|
15508 | 2551 |
text{* Now the recursion rules for definitions: *} |
2552 |
||
22917 | 2553 |
lemma fold1_singleton_def: "g = fold1 f \<Longrightarrow> g {a} = a" |
15508 | 2554 |
by(simp add:fold1_singleton) |
2555 |
||
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
|
2556 |
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
|
2557 |
"\<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
|
2558 |
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
|
2559 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
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
|
2561 |
"\<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
|
2562 |
by simp |
15508 | 2563 |
|
2564 |
subsubsection{* Determinacy for @{term fold1Set} *} |
|
2565 |
||
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2566 |
(*Not actually used!!*) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2567 |
(* |
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
|
2568 |
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
|
2569 |
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
|
2570 |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2571 |
lemma fold_graph_permute: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2572 |
"[|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
|
2573 |
==> 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
|
2574 |
apply (cases "a=b") |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2575 |
apply (auto dest: fold_graph_permute_diff) |
15506 | 2576 |
done |
15376 | 2577 |
|
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
|
2578 |
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
|
2579 |
"fold1Set times A x ==> fold1Set times A y ==> y = x" |
15506 | 2580 |
proof (clarify elim!: fold1Set.cases) |
2581 |
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
|
2582 |
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
|
2583 |
assume By: "fold_graph times id b B y" |
15506 | 2584 |
assume anotA: "a \<notin> A" |
2585 |
assume bnotB: "b \<notin> B" |
|
2586 |
assume eq: "insert a A = insert b B" |
|
2587 |
show "y=x" |
|
2588 |
proof cases |
|
2589 |
assume same: "a=b" |
|
2590 |
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
|
2591 |
thus ?thesis using Ax By same by (blast intro: fold_graph_determ) |
15392 | 2592 |
next |
15506 | 2593 |
assume diff: "a\<noteq>b" |
2594 |
let ?D = "B - {a}" |
|
2595 |
have B: "B = insert a ?D" and A: "A = insert b ?D" |
|
2596 |
and aB: "a \<in> B" and bA: "b \<in> A" |
|
2597 |
using eq anotA bnotB diff by (blast elim!:equalityE)+ |
|
2598 |
with aB bnotB By |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2599 |
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
|
2600 |
by (auto intro: fold_graph_permute simp add: insert_absorb) |
15506 | 2601 |
moreover |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2602 |
have "fold_graph times id a (insert b ?D) x" |
15506 | 2603 |
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
|
2604 |
ultimately show ?thesis by (blast intro: fold_graph_determ) |
15392 | 2605 |
qed |
12396 | 2606 |
qed |
2607 |
||
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
|
2608 |
lemma fold1Set_equality: "fold1Set times A y ==> fold1 times A = y" |
15506 | 2609 |
by (unfold fold1_def) (blast intro: fold1Set_determ) |
2610 |
||
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
|
2611 |
end |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2612 |
*) |
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
|
2613 |
|
15506 | 2614 |
declare |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
2615 |
empty_fold_graphE [rule del] fold_graph.intros [rule del] |
15506 | 2616 |
empty_fold1SetE [rule del] insert_fold1SetE [rule del] |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
19870
diff
changeset
|
2617 |
-- {* No more proofs involve these relations. *} |
15376 | 2618 |
|
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
|
2619 |
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
|
2620 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
context ab_semigroup_mult |
22917 | 2622 |
begin |
2623 |
||
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
|
2624 |
lemma fold1_Un: |
15484 | 2625 |
assumes A: "finite A" "A \<noteq> {}" |
2626 |
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
|
2627 |
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
|
2628 |
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
|
2629 |
(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
|
2630 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2631 |
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
|
2632 |
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
|
2633 |
shows "fold1 times A \<in> A" |
15484 | 2634 |
using A |
2635 |
proof (induct rule:finite_ne_induct) |
|
15506 | 2636 |
case singleton thus ?case by simp |
15484 | 2637 |
next |
2638 |
case insert thus ?case using elem by (force simp add:fold1_insert) |
|
2639 |
qed |
|
2640 |
||
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
|
2641 |
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
|
2642 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
lemma (in ab_semigroup_idem_mult) fold1_Un2: |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2644 |
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
|
2645 |
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
|
2646 |
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
|
2647 |
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
|
2648 |
proof(induct rule:finite_ne_induct) |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
2649 |
case singleton thus ?case by simp |
15484 | 2650 |
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
|
2651 |
case insert thus ?case by (simp add: mult_assoc) |
18423 | 2652 |
qed |
2653 |
||
2654 |
||
22917 | 2655 |
subsubsection {* Fold1 in lattices with @{const inf} and @{const sup} *} |
2656 |
||
2657 |
text{* |
|
2658 |
As an application of @{text fold1} we define infimum |
|
2659 |
and supremum in (not necessarily complete!) lattices |
|
2660 |
over (non-empty) sets by means of @{text fold1}. |
|
2661 |
*} |
|
2662 |
||
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 |
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
|
2664 |
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
|
2665 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
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
|
2667 |
"ab_semigroup_idem_mult inf" |
28823 | 2668 |
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
|
2669 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
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
|
2671 |
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
|
2672 |
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
|
2673 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2674 |
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
|
2675 |
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
|
2676 |
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
|
2677 |
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
|
2678 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour 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 |
lemma fold1_belowI: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2680 |
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
|
2681 |
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
|
2682 |
shows "fold1 inf A \<le> a" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2683 |
proof - |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2684 |
from assms have "A \<noteq> {}" by auto |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2685 |
from `finite A` `A \<noteq> {}` `a \<in> A` show ?thesis |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2686 |
proof (induct rule: finite_ne_induct) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2687 |
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
|
2688 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2689 |
interpret ab_semigroup_idem_mult inf |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2690 |
by (rule ab_semigroup_idem_mult_inf) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2691 |
case (insert x F) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2692 |
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
|
2693 |
thus ?case |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2694 |
proof |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2695 |
assume "a = x" thus ?thesis using insert |
29667 | 2696 |
by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2697 |
next |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2698 |
assume "a \<in> F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2699 |
hence bel: "fold1 inf F \<le> a" by (rule insert) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2700 |
have "inf (fold1 inf (insert x F)) a = inf x (inf (fold1 inf F) a)" |
29667 | 2701 |
using insert by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2702 |
also have "inf (fold1 inf F) a = fold1 inf F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2703 |
using bel by (auto intro: antisym) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2704 |
also have "inf x \<dots> = fold1 inf (insert x F)" |
29667 | 2705 |
using insert by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2706 |
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
|
2707 |
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
|
2708 |
ultimately show ?thesis by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2709 |
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
|
2710 |
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
|
2711 |
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
|
2712 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2713 |
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
|
2714 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2715 |
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
|
2716 |
"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
|
2717 |
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
|
2718 |
(rule dual_lattice) |
15500 | 2719 |
|
24342 | 2720 |
context lattice |
22917 | 2721 |
begin |
2722 |
||
2723 |
definition |
|
29966 | 2724 |
Inf_fin :: "'a set \<Rightarrow> 'a" ("\<Sqinter>\<^bsub>fin\<^esub>_" [900] 900) |
22917 | 2725 |
where |
25062 | 2726 |
"Inf_fin = fold1 inf" |
22917 | 2727 |
|
2728 |
definition |
|
29966 | 2729 |
Sup_fin :: "'a set \<Rightarrow> 'a" ("\<Squnion>\<^bsub>fin\<^esub>_" [900] 900) |
22917 | 2730 |
where |
25062 | 2731 |
"Sup_fin = fold1 sup" |
2732 |
||
29966 | 2733 |
lemma Inf_le_Sup [simp]: "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> \<Sqinter>\<^bsub>fin\<^esub>A \<le> \<Squnion>\<^bsub>fin\<^esub>A" |
24342 | 2734 |
apply(unfold Sup_fin_def Inf_fin_def) |
15500 | 2735 |
apply(subgoal_tac "EX a. a:A") |
2736 |
prefer 2 apply blast |
|
2737 |
apply(erule exE) |
|
22388 | 2738 |
apply(rule order_trans) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2739 |
apply(erule (1) fold1_belowI) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
2740 |
apply(erule (1) lower_semilattice.fold1_belowI [OF dual_lattice]) |
15500 | 2741 |
done |
2742 |
||
24342 | 2743 |
lemma sup_Inf_absorb [simp]: |
29966 | 2744 |
"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
|
2745 |
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
|
2746 |
apply(simp add: Inf_fin_def sup_absorb2 fold1_belowI) |
15504 | 2747 |
done |
2748 |
||
24342 | 2749 |
lemma inf_Sup_absorb [simp]: |
29966 | 2750 |
"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
|
2751 |
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
|
2752 |
lower_semilattice.fold1_belowI [OF dual_lattice]) |
24342 | 2753 |
|
2754 |
end |
|
2755 |
||
2756 |
context distrib_lattice |
|
2757 |
begin |
|
2758 |
||
2759 |
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
|
2760 |
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
|
2761 |
and "A \<noteq> {}" |
29966 | 2762 |
shows "sup x (\<Sqinter>\<^bsub>fin\<^esub>A) = \<Sqinter>\<^bsub>fin\<^esub>{sup x a|a. a \<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
|
2763 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2764 |
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
|
2765 |
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
|
2766 |
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
|
2767 |
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
|
2768 |
hom_fold1_commute [where h="sup x", OF sup_inf_distrib1]) |
26792 | 2769 |
(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
|
2770 |
qed |
18423 | 2771 |
|
24342 | 2772 |
lemma sup_Inf2_distrib: |
2773 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
29966 | 2774 |
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 | 2775 |
using A proof (induct rule: finite_ne_induct) |
15500 | 2776 |
case singleton thus ?case |
24342 | 2777 |
by (simp add: sup_Inf1_distrib [OF B] fold1_singleton_def [OF Inf_fin_def]) |
15500 | 2778 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2779 |
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
|
2780 |
by (rule ab_semigroup_idem_mult_inf) |
15500 | 2781 |
case (insert x A) |
25062 | 2782 |
have finB: "finite {sup x b |b. b \<in> B}" |
2783 |
by(rule finite_surj[where f = "sup x", OF B(1)], auto) |
|
2784 |
have finAB: "finite {sup a b |a b. a \<in> A \<and> b \<in> B}" |
|
15500 | 2785 |
proof - |
25062 | 2786 |
have "{sup a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {sup a b})" |
15500 | 2787 |
by blast |
15517 | 2788 |
thus ?thesis by(simp add: insert(1) B(1)) |
15500 | 2789 |
qed |
25062 | 2790 |
have ne: "{sup a b |a b. a \<in> A \<and> b \<in> B} \<noteq> {}" using insert B by blast |
29966 | 2791 |
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
|
2792 |
using insert by (simp add: fold1_insert_idem_def [OF Inf_fin_def]) |
29966 | 2793 |
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) |
2794 |
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 | 2795 |
using insert by(simp add:sup_Inf1_distrib[OF B]) |
29966 | 2796 |
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})" |
2797 |
(is "_ = \<Sqinter>\<^bsub>fin\<^esub>?M") |
|
15500 | 2798 |
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
|
2799 |
by (simp add: Inf_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 2800 |
also have "?M = {sup a b |a b. a \<in> insert x A \<and> b \<in> B}" |
15500 | 2801 |
by blast |
2802 |
finally show ?case . |
|
2803 |
qed |
|
2804 |
||
24342 | 2805 |
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
|
2806 |
assumes "finite A" and "A \<noteq> {}" |
29966 | 2807 |
shows "inf x (\<Squnion>\<^bsub>fin\<^esub>A) = \<Squnion>\<^bsub>fin\<^esub>{inf x a|a. a \<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
|
2808 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2809 |
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
|
2810 |
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
|
2811 |
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
|
2812 |
by (simp add: Sup_fin_def image_def hom_fold1_commute [where h="inf x", OF inf_sup_distrib1]) |
26792 | 2813 |
(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
|
2814 |
qed |
18423 | 2815 |
|
24342 | 2816 |
lemma inf_Sup2_distrib: |
2817 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
29966 | 2818 |
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 | 2819 |
using A proof (induct rule: finite_ne_induct) |
18423 | 2820 |
case singleton thus ?case |
24342 | 2821 |
by(simp add: inf_Sup1_distrib [OF B] fold1_singleton_def [OF Sup_fin_def]) |
18423 | 2822 |
next |
2823 |
case (insert x A) |
|
25062 | 2824 |
have finB: "finite {inf x b |b. b \<in> B}" |
2825 |
by(rule finite_surj[where f = "%b. inf x b", OF B(1)], auto) |
|
2826 |
have finAB: "finite {inf a b |a b. a \<in> A \<and> b \<in> B}" |
|
18423 | 2827 |
proof - |
25062 | 2828 |
have "{inf a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {inf a b})" |
18423 | 2829 |
by blast |
2830 |
thus ?thesis by(simp add: insert(1) B(1)) |
|
2831 |
qed |
|
25062 | 2832 |
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
|
2833 |
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
|
2834 |
by (rule ab_semigroup_idem_mult_sup) |
29966 | 2835 |
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
|
2836 |
using insert by (simp add: fold1_insert_idem_def [OF Sup_fin_def]) |
29966 | 2837 |
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) |
2838 |
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 | 2839 |
using insert by(simp add:inf_Sup1_distrib[OF B]) |
29966 | 2840 |
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})" |
2841 |
(is "_ = \<Squnion>\<^bsub>fin\<^esub>?M") |
|
18423 | 2842 |
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
|
2843 |
by (simp add: Sup_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 2844 |
also have "?M = {inf a b |a b. a \<in> insert x A \<and> b \<in> B}" |
18423 | 2845 |
by blast |
2846 |
finally show ?case . |
|
2847 |
qed |
|
2848 |
||
24342 | 2849 |
end |
2850 |
||
2851 |
context complete_lattice |
|
2852 |
begin |
|
2853 |
||
22917 | 2854 |
text {* |
24342 | 2855 |
Coincidence on finite sets in complete lattices: |
22917 | 2856 |
*} |
2857 |
||
24342 | 2858 |
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
|
2859 |
assumes "finite A" and "A \<noteq> {}" |
29966 | 2860 |
shows "\<Sqinter>\<^bsub>fin\<^esub>A = Inf 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
|
2861 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2862 |
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
|
2863 |
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
|
2864 |
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
|
2865 |
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
|
2866 |
(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
|
2867 |
qed |
22917 | 2868 |
|
24342 | 2869 |
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
|
2870 |
assumes "finite A" and "A \<noteq> {}" |
29966 | 2871 |
shows "\<Squnion>\<^bsub>fin\<^esub>A = Sup 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
|
2872 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2873 |
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
|
2874 |
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
|
2875 |
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
|
2876 |
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
|
2877 |
(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
|
2878 |
qed |
22917 | 2879 |
|
24342 | 2880 |
end |
2881 |
||
22917 | 2882 |
|
2883 |
subsubsection {* Fold1 in linear orders with @{const min} and @{const max} *} |
|
2884 |
||
2885 |
text{* |
|
2886 |
As an application of @{text fold1} we define minimum |
|
2887 |
and maximum in (not necessarily complete!) linear orders |
|
2888 |
over (non-empty) sets by means of @{text fold1}. |
|
2889 |
*} |
|
2890 |
||
24342 | 2891 |
context linorder |
22917 | 2892 |
begin |
2893 |
||
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
|
2894 |
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
|
2895 |
"ab_semigroup_idem_mult min" |
28823 | 2896 |
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
|
2897 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2898 |
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
|
2899 |
"ab_semigroup_idem_mult max" |
28823 | 2900 |
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
|
2901 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2902 |
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
|
2903 |
"lower_semilattice (op \<le>) (op <) min" |
28823 | 2904 |
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
|
2905 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2906 |
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
|
2907 |
"lower_semilattice (op \<ge>) (op >) max" |
28823 | 2908 |
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
|
2909 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2910 |
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
|
2911 |
"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
|
2912 |
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
|
2913 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2914 |
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
|
2915 |
"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
|
2916 |
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
|
2917 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2918 |
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
|
2919 |
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
|
2920 |
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
|
2921 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2922 |
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
|
2923 |
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
|
2924 |
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
|
2925 |
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
|
2926 |
(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
|
2927 |
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
|
2928 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2929 |
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
|
2930 |
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
|
2931 |
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
|
2932 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2933 |
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
|
2934 |
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
|
2935 |
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
|
2936 |
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
|
2937 |
(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
|
2938 |
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
|
2939 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2940 |
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
|
2941 |
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
|
2942 |
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
|
2943 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2944 |
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
|
2945 |
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
|
2946 |
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
|
2947 |
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
|
2948 |
(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
|
2949 |
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
|
2950 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2951 |
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
|
2952 |
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
|
2953 |
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
|
2954 |
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
|
2955 |
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
|
2956 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2957 |
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
|
2958 |
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
|
2959 |
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
|
2960 |
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
|
2961 |
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
|
2962 |
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
|
2963 |
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
|
2964 |
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
|
2965 |
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
|
2966 |
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
|
2967 |
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
|
2968 |
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
|
2969 |
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
|
2970 |
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
|
2971 |
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
|
2972 |
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
|
2973 |
|
22917 | 2974 |
definition |
2975 |
Min :: "'a set \<Rightarrow> 'a" |
|
2976 |
where |
|
2977 |
"Min = fold1 min" |
|
2978 |
||
2979 |
definition |
|
2980 |
Max :: "'a set \<Rightarrow> 'a" |
|
2981 |
where |
|
2982 |
"Max = fold1 max" |
|
2983 |
||
2984 |
lemmas Min_singleton [simp] = fold1_singleton_def [OF Min_def] |
|
2985 |
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
|
2986 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2987 |
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
|
2988 |
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
|
2989 |
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
|
2990 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
2991 |
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
|
2992 |
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
|
2993 |
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
|
2994 |
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
|
2995 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
2996 |
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
|
2997 |
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
|
2998 |
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
|
2999 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3000 |
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
|
3001 |
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
|
3002 |
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
|
3003 |
qed |
15392 | 3004 |
|
24427 | 3005 |
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
|
3006 |
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
|
3007 |
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
|
3008 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3009 |
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
|
3010 |
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
|
3011 |
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
|
3012 |
qed |
15392 | 3013 |
|
24427 | 3014 |
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
|
3015 |
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
|
3016 |
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
|
3017 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3018 |
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
|
3019 |
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
|
3020 |
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
|
3021 |
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
|
3022 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3023 |
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
|
3024 |
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
|
3025 |
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
|
3026 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3027 |
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
|
3028 |
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
|
3029 |
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
|
3030 |
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
|
3031 |
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
|
3032 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3033 |
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
|
3034 |
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
|
3035 |
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
|
3036 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3037 |
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
|
3038 |
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
|
3039 |
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
|
3040 |
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
|
3041 |
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
|
3042 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3043 |
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
|
3044 |
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
|
3045 |
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
|
3046 |
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
|
3047 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3048 |
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
|
3049 |
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
|
3050 |
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
|
3051 |
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
|
3052 |
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
|
3053 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3054 |
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
|
3055 |
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
|
3056 |
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
|
3057 |
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
|
3058 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3059 |
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
|
3060 |
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
|
3061 |
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
|
3062 |
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
|
3063 |
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
|
3064 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3065 |
lemma Min_le [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
3066 |
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
|
3067 |
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
|
3068 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3069 |
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
|
3070 |
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
|
3071 |
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
|
3072 |
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
|
3073 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3074 |
lemma Max_ge [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
3075 |
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
|
3076 |
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
|
3077 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3078 |
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
|
3079 |
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
|
3080 |
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
|
3081 |
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
|
3082 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3083 |
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
|
3084 |
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
|
3085 |
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
|
3086 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3087 |
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
|
3088 |
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
|
3089 |
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
|
3090 |
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
|
3091 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3092 |
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
|
3093 |
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
|
3094 |
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
|
3095 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3096 |
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
|
3097 |
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
|
3098 |
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
|
3099 |
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
|
3100 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3101 |
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
|
3102 |
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
|
3103 |
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
|
3104 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3105 |
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
|
3106 |
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
|
3107 |
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
|
3108 |
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
|
3109 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3110 |
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
|
3111 |
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
|
3112 |
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
|
3113 |
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
|
3114 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3115 |
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
|
3116 |
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
|
3117 |
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
|
3118 |
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
|
3119 |
qed |
18493 | 3120 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
3121 |
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
|
3122 |
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
|
3123 |
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
|
3124 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3125 |
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
|
3126 |
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
|
3127 |
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
|
3128 |
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
|
3129 |
qed |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
3130 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
3131 |
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
|
3132 |
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
|
3133 |
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
|
3134 |
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
|
3135 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3136 |
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
|
3137 |
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
|
3138 |
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
|
3139 |
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
|
3140 |
qed |
22917 | 3141 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
3142 |
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
|
3143 |
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
|
3144 |
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
|
3145 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3146 |
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
|
3147 |
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
|
3148 |
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
|
3149 |
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
|
3150 |
qed |
22917 | 3151 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
24268
diff
changeset
|
3152 |
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
|
3153 |
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
|
3154 |
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
|
3155 |
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
|
3156 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3157 |
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
|
3158 |
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
|
3159 |
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
|
3160 |
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
|
3161 |
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
|
3162 |
|
30325 | 3163 |
lemma Min_eqI: |
3164 |
assumes "finite A" |
|
3165 |
assumes "\<And>y. y \<in> A \<Longrightarrow> y \<ge> x" |
|
3166 |
and "x \<in> A" |
|
3167 |
shows "Min A = x" |
|
3168 |
proof (rule antisym) |
|
3169 |
from `x \<in> A` have "A \<noteq> {}" by auto |
|
3170 |
with assms show "Min A \<ge> x" by simp |
|
3171 |
next |
|
3172 |
from assms show "x \<ge> Min A" by simp |
|
3173 |
qed |
|
3174 |
||
3175 |
lemma Max_eqI: |
|
3176 |
assumes "finite A" |
|
3177 |
assumes "\<And>y. y \<in> A \<Longrightarrow> y \<le> x" |
|
3178 |
and "x \<in> A" |
|
3179 |
shows "Max A = x" |
|
3180 |
proof (rule antisym) |
|
3181 |
from `x \<in> A` have "A \<noteq> {}" by auto |
|
3182 |
with assms show "Max A \<le> x" by simp |
|
3183 |
next |
|
3184 |
from assms show "x \<le> Max A" by simp |
|
3185 |
qed |
|
3186 |
||
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
|
3187 |
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
|
3188 |
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
|
3189 |
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
|
3190 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3191 |
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
|
3192 |
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
|
3193 |
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
|
3194 |
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
|
3195 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
3196 |
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
|
3197 |
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
|
3198 |
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
|
3199 |
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
|
3200 |
note Max = Max_def |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
3201 |
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
|
3202 |
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
|
3203 |
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
|
3204 |
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
|
3205 |
qed |
22917 | 3206 |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3207 |
lemma finite_linorder_induct[consumes 1, case_names empty insert]: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3208 |
"finite A \<Longrightarrow> P {} \<Longrightarrow> |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3209 |
(!!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
|
3210 |
\<Longrightarrow> P A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3211 |
proof (induct A rule: measure_induct_rule[where f=card]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3212 |
fix A :: "'a set" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3213 |
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
|
3214 |
(!!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
|
3215 |
\<Longrightarrow> P B" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3216 |
and "finite A" and "P {}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3217 |
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
|
3218 |
show "P A" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
3219 |
proof (cases "A = {}") |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3220 |
assume "A = {}" thus "P A" using `P {}` by simp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3221 |
next |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3222 |
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
|
3223 |
assume "A \<noteq> {}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3224 |
with `finite A` have "Max A : A" by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3225 |
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
|
3226 |
note card_Diff1_less[OF `finite A` `Max A : A`] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3227 |
moreover have "finite ?B" using `finite A` by simp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3228 |
ultimately have "P ?B" using `P {}` step IH by blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3229 |
moreover have "\<forall>a\<in>?B. a < Max A" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
3230 |
using Max_ge [OF `finite A`] by fastsimp |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3231 |
ultimately show "P A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3232 |
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
|
3233 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3234 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
3235 |
|
22917 | 3236 |
end |
3237 |
||
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24342
diff
changeset
|
3238 |
context ordered_ab_semigroup_add |
22917 | 3239 |
begin |
3240 |
||
3241 |
lemma add_Min_commute: |
|
3242 |
fixes k |
|
25062 | 3243 |
assumes "finite N" and "N \<noteq> {}" |
3244 |
shows "k + Min N = Min {k + m | m. m \<in> N}" |
|
3245 |
proof - |
|
3246 |
have "\<And>x y. k + min x y = min (k + x) (k + y)" |
|
3247 |
by (simp add: min_def not_le) |
|
3248 |
(blast intro: antisym less_imp_le add_left_mono) |
|
3249 |
with assms show ?thesis |
|
3250 |
using hom_Min_commute [of "plus k" N] |
|
3251 |
by simp (blast intro: arg_cong [where f = Min]) |
|
3252 |
qed |
|
22917 | 3253 |
|
3254 |
lemma add_Max_commute: |
|
3255 |
fixes k |
|
25062 | 3256 |
assumes "finite N" and "N \<noteq> {}" |
3257 |
shows "k + Max N = Max {k + m | m. m \<in> N}" |
|
3258 |
proof - |
|
3259 |
have "\<And>x y. k + max x y = max (k + x) (k + y)" |
|
3260 |
by (simp add: max_def not_le) |
|
3261 |
(blast intro: antisym less_imp_le add_left_mono) |
|
3262 |
with assms show ?thesis |
|
3263 |
using hom_Max_commute [of "plus k" N] |
|
3264 |
by simp (blast intro: arg_cong [where f = Max]) |
|
3265 |
qed |
|
22917 | 3266 |
|
3267 |
end |
|
3268 |
||
31453
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3269 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3270 |
subsection {* Expressing set operations via @{const fold} *} |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3271 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3272 |
lemma (in fun_left_comm) fun_left_comm_apply: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3273 |
"fun_left_comm (\<lambda>x. f (g x))" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3274 |
proof |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3275 |
qed (simp_all add: fun_left_comm) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3276 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3277 |
lemma (in fun_left_comm_idem) fun_left_comm_idem_apply: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3278 |
"fun_left_comm_idem (\<lambda>x. f (g x))" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3279 |
by (rule fun_left_comm_idem.intro, rule fun_left_comm_apply, unfold_locales) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3280 |
(simp_all add: fun_left_idem) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3281 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3282 |
lemma fun_left_comm_idem_insert: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3283 |
"fun_left_comm_idem insert" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3284 |
proof |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3285 |
qed auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3286 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3287 |
lemma fun_left_comm_idem_remove: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3288 |
"fun_left_comm_idem (\<lambda>x A. A - {x})" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3289 |
proof |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3290 |
qed auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3291 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3292 |
lemma fun_left_comm_idem_inter: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3293 |
"fun_left_comm_idem op \<inter>" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3294 |
proof |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3295 |
qed auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3296 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3297 |
lemma fun_left_comm_idem_union: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3298 |
"fun_left_comm_idem op \<union>" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3299 |
proof |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3300 |
qed auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3301 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3302 |
lemma union_fold_insert: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3303 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3304 |
shows "A \<union> B = fold insert B A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3305 |
proof - |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3306 |
interpret fun_left_comm_idem insert by (fact fun_left_comm_idem_insert) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3307 |
from `finite A` show ?thesis by (induct A arbitrary: B) simp_all |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3308 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3309 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3310 |
lemma minus_fold_remove: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3311 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3312 |
shows "B - A = fold (\<lambda>x A. A - {x}) B A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3313 |
proof - |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3314 |
interpret fun_left_comm_idem "\<lambda>x A. A - {x}" by (fact fun_left_comm_idem_remove) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3315 |
from `finite A` show ?thesis by (induct A arbitrary: B) auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3316 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3317 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3318 |
lemma inter_Inter_fold_inter: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3319 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3320 |
shows "B \<inter> Inter A = fold (op \<inter>) B A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3321 |
proof - |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3322 |
interpret fun_left_comm_idem "op \<inter>" by (fact fun_left_comm_idem_inter) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3323 |
from `finite A` show ?thesis by (induct A arbitrary: B) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3324 |
(simp_all add: fold_fun_comm Int_commute) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3325 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3326 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3327 |
lemma union_Union_fold_union: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3328 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3329 |
shows "B \<union> Union A = fold (op \<union>) B A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3330 |
proof - |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3331 |
interpret fun_left_comm_idem "op \<union>" by (fact fun_left_comm_idem_union) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3332 |
from `finite A` show ?thesis by (induct A arbitrary: B) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3333 |
(simp_all add: fold_fun_comm Un_commute) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3334 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3335 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3336 |
lemma Inter_fold_inter: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3337 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3338 |
shows "Inter A = fold (op \<inter>) UNIV A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3339 |
using assms inter_Inter_fold_inter [of A UNIV] by simp |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3340 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3341 |
lemma Union_fold_union: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3342 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3343 |
shows "Union A = fold (op \<union>) {} A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3344 |
using assms union_Union_fold_union [of A "{}"] by simp |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3345 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3346 |
lemma inter_INTER_fold_inter: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3347 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3348 |
shows "B \<inter> INTER A f = fold (\<lambda>A. op \<inter> (f A)) B A" (is "?inter = ?fold") |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3349 |
proof (rule sym) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3350 |
interpret fun_left_comm_idem "op \<inter>" by (fact fun_left_comm_idem_inter) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3351 |
interpret fun_left_comm_idem "\<lambda>A. op \<inter> (f A)" by (fact fun_left_comm_idem_apply) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3352 |
from `finite A` show "?fold = ?inter" by (induct A arbitrary: B) auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3353 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3354 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3355 |
lemma union_UNION_fold_union: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3356 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3357 |
shows "B \<union> UNION A f = fold (\<lambda>A. op \<union> (f A)) B A" (is "?union = ?fold") |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3358 |
proof (rule sym) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3359 |
interpret fun_left_comm_idem "op \<union>" by (fact fun_left_comm_idem_union) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3360 |
interpret fun_left_comm_idem "\<lambda>A. op \<union> (f A)" by (fact fun_left_comm_idem_apply) |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3361 |
from `finite A` show "?fold = ?union" by (induct A arbitrary: B) auto |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3362 |
qed |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3363 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3364 |
lemma INTER_fold_inter: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3365 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3366 |
shows "INTER A f = fold (\<lambda>A. op \<inter> (f A)) UNIV A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3367 |
using assms inter_INTER_fold_inter [of A UNIV] by simp |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3368 |
|
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3369 |
lemma UNION_fold_union: |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3370 |
assumes "finite A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3371 |
shows "UNION A f = fold (\<lambda>A. op \<union> (f A)) {} A" |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3372 |
using assms union_UNION_fold_union [of A "{}"] by simp |
78280bd2860a
lemmas about basic set operations and Finite_Set.fold
haftmann
parents:
31438
diff
changeset
|
3373 |
|
25571
c9e39eafc7a0
instantiation target rather than legacy instance
haftmann
parents:
25502
diff
changeset
|
3374 |
end |