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