author | berghofe |
Wed, 11 Jul 2007 11:14:51 +0200 | |
changeset 23746 | a455e69c31cc |
parent 23350 | 50c5b0912a0c |
child 27699 | 489e3f33af0e |
permissions | -rw-r--r-- |
14706 | 1 |
(* Title: HOL/Algebra/FiniteProduct.thy |
13936 | 2 |
ID: $Id$ |
3 |
Author: Clemens Ballarin, started 19 November 2002 |
|
4 |
||
5 |
This file is largely based on HOL/Finite_Set.thy. |
|
6 |
*) |
|
7 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
8 |
theory FiniteProduct imports Group begin |
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
9 |
|
13936 | 10 |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
11 |
section {* Product Operator for Commutative Monoids *} |
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
12 |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
13 |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
14 |
subsection {* Inductive Definition of a Relation for Products over Sets *} |
13936 | 15 |
|
14750 | 16 |
text {* Instantiation of locale @{text LC} of theory @{text Finite_Set} is not |
17 |
possible, because here we have explicit typing rules like |
|
18 |
@{text "x \<in> carrier G"}. We introduce an explicit argument for the domain |
|
14651 | 19 |
@{text D}. *} |
13936 | 20 |
|
23746 | 21 |
inductive_set |
13936 | 22 |
foldSetD :: "['a set, 'b => 'a => 'a, 'a] => ('b set * 'a) set" |
23746 | 23 |
for D :: "'a set" and f :: "'b => 'a => 'a" and e :: 'a |
24 |
where |
|
14750 | 25 |
emptyI [intro]: "e \<in> D ==> ({}, e) \<in> foldSetD D f e" |
23746 | 26 |
| insertI [intro]: "[| x ~: A; f x y \<in> D; (A, y) \<in> foldSetD D f e |] ==> |
14750 | 27 |
(insert x A, f x y) \<in> foldSetD D f e" |
13936 | 28 |
|
14750 | 29 |
inductive_cases empty_foldSetDE [elim!]: "({}, x) \<in> foldSetD D f e" |
13936 | 30 |
|
31 |
constdefs |
|
32 |
foldD :: "['a set, 'b => 'a => 'a, 'a, 'b set] => 'a" |
|
14750 | 33 |
"foldD D f e A == THE x. (A, x) \<in> foldSetD D f e" |
13936 | 34 |
|
35 |
lemma foldSetD_closed: |
|
14750 | 36 |
"[| (A, z) \<in> foldSetD D f e ; e \<in> D; !!x y. [| x \<in> A; y \<in> D |] ==> f x y \<in> D |
37 |
|] ==> z \<in> D"; |
|
23746 | 38 |
by (erule foldSetD.cases) auto |
13936 | 39 |
|
40 |
lemma Diff1_foldSetD: |
|
14750 | 41 |
"[| (A - {x}, y) \<in> foldSetD D f e; x \<in> A; f x y \<in> D |] ==> |
42 |
(A, f x y) \<in> foldSetD D f e" |
|
13936 | 43 |
apply (erule insert_Diff [THEN subst], rule foldSetD.intros) |
44 |
apply auto |
|
45 |
done |
|
46 |
||
14750 | 47 |
lemma foldSetD_imp_finite [simp]: "(A, x) \<in> foldSetD D f e ==> finite A" |
13936 | 48 |
by (induct set: foldSetD) auto |
49 |
||
50 |
lemma finite_imp_foldSetD: |
|
14750 | 51 |
"[| finite A; e \<in> D; !!x y. [| x \<in> A; y \<in> D |] ==> f x y \<in> D |] ==> |
52 |
EX x. (A, x) \<in> foldSetD D f e" |
|
22265 | 53 |
proof (induct set: finite) |
13936 | 54 |
case empty then show ?case by auto |
55 |
next |
|
15328 | 56 |
case (insert x F) |
14750 | 57 |
then obtain y where y: "(F, y) \<in> foldSetD D f e" by auto |
58 |
with insert have "y \<in> D" by (auto dest: foldSetD_closed) |
|
59 |
with y and insert have "(insert x F, f x y) \<in> foldSetD D f e" |
|
13936 | 60 |
by (intro foldSetD.intros) auto |
61 |
then show ?case .. |
|
62 |
qed |
|
63 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
64 |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
65 |
subsection {* Left-Commutative Operations *} |
13936 | 66 |
|
67 |
locale LCD = |
|
68 |
fixes B :: "'b set" |
|
69 |
and D :: "'a set" |
|
70 |
and f :: "'b => 'a => 'a" (infixl "\<cdot>" 70) |
|
71 |
assumes left_commute: |
|
14750 | 72 |
"[| x \<in> B; y \<in> B; z \<in> D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)" |
73 |
and f_closed [simp, intro!]: "!!x y. [| x \<in> B; y \<in> D |] ==> f x y \<in> D" |
|
13936 | 74 |
|
75 |
lemma (in LCD) foldSetD_closed [dest]: |
|
14750 | 76 |
"(A, z) \<in> foldSetD D f e ==> z \<in> D"; |
23746 | 77 |
by (erule foldSetD.cases) auto |
13936 | 78 |
|
79 |
lemma (in LCD) Diff1_foldSetD: |
|
14750 | 80 |
"[| (A - {x}, y) \<in> foldSetD D f e; x \<in> A; A \<subseteq> B |] ==> |
81 |
(A, f x y) \<in> foldSetD D f e" |
|
82 |
apply (subgoal_tac "x \<in> B") |
|
13936 | 83 |
prefer 2 apply fast |
84 |
apply (erule insert_Diff [THEN subst], rule foldSetD.intros) |
|
85 |
apply auto |
|
86 |
done |
|
87 |
||
88 |
lemma (in LCD) foldSetD_imp_finite [simp]: |
|
14750 | 89 |
"(A, x) \<in> foldSetD D f e ==> finite A" |
13936 | 90 |
by (induct set: foldSetD) auto |
91 |
||
92 |
lemma (in LCD) finite_imp_foldSetD: |
|
14750 | 93 |
"[| finite A; A \<subseteq> B; e \<in> D |] ==> EX x. (A, x) \<in> foldSetD D f e" |
22265 | 94 |
proof (induct set: finite) |
13936 | 95 |
case empty then show ?case by auto |
96 |
next |
|
15328 | 97 |
case (insert x F) |
14750 | 98 |
then obtain y where y: "(F, y) \<in> foldSetD D f e" by auto |
99 |
with insert have "y \<in> D" by auto |
|
100 |
with y and insert have "(insert x F, f x y) \<in> foldSetD D f e" |
|
13936 | 101 |
by (intro foldSetD.intros) auto |
102 |
then show ?case .. |
|
103 |
qed |
|
104 |
||
105 |
lemma (in LCD) foldSetD_determ_aux: |
|
14750 | 106 |
"e \<in> D ==> \<forall>A x. A \<subseteq> B & card A < n --> (A, x) \<in> foldSetD D f e --> |
107 |
(\<forall>y. (A, y) \<in> foldSetD D f e --> y = x)" |
|
13936 | 108 |
apply (induct n) |
109 |
apply (auto simp add: less_Suc_eq) (* slow *) |
|
110 |
apply (erule foldSetD.cases) |
|
111 |
apply blast |
|
112 |
apply (erule foldSetD.cases) |
|
113 |
apply blast |
|
114 |
apply clarify |
|
115 |
txt {* force simplification of @{text "card A < card (insert ...)"}. *} |
|
116 |
apply (erule rev_mp) |
|
117 |
apply (simp add: less_Suc_eq_le) |
|
118 |
apply (rule impI) |
|
23746 | 119 |
apply (rename_tac xa Aa ya xb Ab yb, case_tac "xa = xb") |
13936 | 120 |
apply (subgoal_tac "Aa = Ab") |
121 |
prefer 2 apply (blast elim!: equalityE) |
|
122 |
apply blast |
|
123 |
txt {* case @{prop "xa \<notin> xb"}. *} |
|
14750 | 124 |
apply (subgoal_tac "Aa - {xb} = Ab - {xa} & xb \<in> Aa & xa \<in> Ab") |
13936 | 125 |
prefer 2 apply (blast elim!: equalityE) |
126 |
apply clarify |
|
127 |
apply (subgoal_tac "Aa = insert xb Ab - {xa}") |
|
128 |
prefer 2 apply blast |
|
14750 | 129 |
apply (subgoal_tac "card Aa \<le> card Ab") |
13936 | 130 |
prefer 2 |
131 |
apply (rule Suc_le_mono [THEN subst]) |
|
132 |
apply (simp add: card_Suc_Diff1) |
|
133 |
apply (rule_tac A1 = "Aa - {xb}" in finite_imp_foldSetD [THEN exE]) |
|
134 |
apply (blast intro: foldSetD_imp_finite finite_Diff) |
|
135 |
apply best |
|
136 |
apply assumption |
|
137 |
apply (frule (1) Diff1_foldSetD) |
|
138 |
apply best |
|
139 |
apply (subgoal_tac "ya = f xb x") |
|
140 |
prefer 2 |
|
14750 | 141 |
apply (subgoal_tac "Aa \<subseteq> B") |
13936 | 142 |
prefer 2 apply best (* slow *) |
143 |
apply (blast del: equalityCE) |
|
14750 | 144 |
apply (subgoal_tac "(Ab - {xa}, x) \<in> foldSetD D f e") |
13936 | 145 |
prefer 2 apply simp |
146 |
apply (subgoal_tac "yb = f xa x") |
|
147 |
prefer 2 |
|
148 |
apply (blast del: equalityCE dest: Diff1_foldSetD) |
|
149 |
apply (simp (no_asm_simp)) |
|
150 |
apply (rule left_commute) |
|
151 |
apply assumption |
|
152 |
apply best (* slow *) |
|
153 |
apply best |
|
154 |
done |
|
155 |
||
156 |
lemma (in LCD) foldSetD_determ: |
|
14750 | 157 |
"[| (A, x) \<in> foldSetD D f e; (A, y) \<in> foldSetD D f e; e \<in> D; A \<subseteq> B |] |
13936 | 158 |
==> y = x" |
159 |
by (blast intro: foldSetD_determ_aux [rule_format]) |
|
160 |
||
161 |
lemma (in LCD) foldD_equality: |
|
14750 | 162 |
"[| (A, y) \<in> foldSetD D f e; e \<in> D; A \<subseteq> B |] ==> foldD D f e A = y" |
13936 | 163 |
by (unfold foldD_def) (blast intro: foldSetD_determ) |
164 |
||
165 |
lemma foldD_empty [simp]: |
|
14750 | 166 |
"e \<in> D ==> foldD D f e {} = e" |
13936 | 167 |
by (unfold foldD_def) blast |
168 |
||
169 |
lemma (in LCD) foldD_insert_aux: |
|
14750 | 170 |
"[| x ~: A; x \<in> B; e \<in> D; A \<subseteq> B |] ==> |
171 |
((insert x A, v) \<in> foldSetD D f e) = |
|
172 |
(EX y. (A, y) \<in> foldSetD D f e & v = f x y)" |
|
13936 | 173 |
apply auto |
174 |
apply (rule_tac A1 = A in finite_imp_foldSetD [THEN exE]) |
|
175 |
apply (fastsimp dest: foldSetD_imp_finite) |
|
176 |
apply assumption |
|
177 |
apply assumption |
|
178 |
apply (blast intro: foldSetD_determ) |
|
179 |
done |
|
180 |
||
181 |
lemma (in LCD) foldD_insert: |
|
14750 | 182 |
"[| finite A; x ~: A; x \<in> B; e \<in> D; A \<subseteq> B |] ==> |
13936 | 183 |
foldD D f e (insert x A) = f x (foldD D f e A)" |
184 |
apply (unfold foldD_def) |
|
185 |
apply (simp add: foldD_insert_aux) |
|
186 |
apply (rule the_equality) |
|
187 |
apply (auto intro: finite_imp_foldSetD |
|
188 |
cong add: conj_cong simp add: foldD_def [symmetric] foldD_equality) |
|
189 |
done |
|
190 |
||
191 |
lemma (in LCD) foldD_closed [simp]: |
|
14750 | 192 |
"[| finite A; e \<in> D; A \<subseteq> B |] ==> foldD D f e A \<in> D" |
22265 | 193 |
proof (induct set: finite) |
13936 | 194 |
case empty then show ?case by (simp add: foldD_empty) |
195 |
next |
|
196 |
case insert then show ?case by (simp add: foldD_insert) |
|
197 |
qed |
|
198 |
||
199 |
lemma (in LCD) foldD_commute: |
|
14750 | 200 |
"[| finite A; x \<in> B; e \<in> D; A \<subseteq> B |] ==> |
13936 | 201 |
f x (foldD D f e A) = foldD D f (f x e) A" |
22265 | 202 |
apply (induct set: finite) |
13936 | 203 |
apply simp |
204 |
apply (auto simp add: left_commute foldD_insert) |
|
205 |
done |
|
206 |
||
207 |
lemma Int_mono2: |
|
14750 | 208 |
"[| A \<subseteq> C; B \<subseteq> C |] ==> A Int B \<subseteq> C" |
13936 | 209 |
by blast |
210 |
||
211 |
lemma (in LCD) foldD_nest_Un_Int: |
|
14750 | 212 |
"[| finite A; finite C; e \<in> D; A \<subseteq> B; C \<subseteq> B |] ==> |
13936 | 213 |
foldD D f (foldD D f e C) A = foldD D f (foldD D f e (A Int C)) (A Un C)" |
22265 | 214 |
apply (induct set: finite) |
13936 | 215 |
apply simp |
216 |
apply (simp add: foldD_insert foldD_commute Int_insert_left insert_absorb |
|
217 |
Int_mono2 Un_subset_iff) |
|
218 |
done |
|
219 |
||
220 |
lemma (in LCD) foldD_nest_Un_disjoint: |
|
14750 | 221 |
"[| finite A; finite B; A Int B = {}; e \<in> D; A \<subseteq> B; C \<subseteq> B |] |
13936 | 222 |
==> foldD D f e (A Un B) = foldD D f (foldD D f e B) A" |
223 |
by (simp add: foldD_nest_Un_Int) |
|
224 |
||
225 |
-- {* Delete rules to do with @{text foldSetD} relation. *} |
|
226 |
||
227 |
declare foldSetD_imp_finite [simp del] |
|
228 |
empty_foldSetDE [rule del] |
|
229 |
foldSetD.intros [rule del] |
|
230 |
declare (in LCD) |
|
231 |
foldSetD_closed [rule del] |
|
232 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
233 |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
234 |
subsection {* Commutative Monoids *} |
13936 | 235 |
|
236 |
text {* |
|
237 |
We enter a more restrictive context, with @{text "f :: 'a => 'a => 'a"} |
|
238 |
instead of @{text "'b => 'a => 'a"}. |
|
239 |
*} |
|
240 |
||
241 |
locale ACeD = |
|
242 |
fixes D :: "'a set" |
|
243 |
and f :: "'a => 'a => 'a" (infixl "\<cdot>" 70) |
|
244 |
and e :: 'a |
|
14750 | 245 |
assumes ident [simp]: "x \<in> D ==> x \<cdot> e = x" |
246 |
and commute: "[| x \<in> D; y \<in> D |] ==> x \<cdot> y = y \<cdot> x" |
|
247 |
and assoc: "[| x \<in> D; y \<in> D; z \<in> D |] ==> (x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)" |
|
248 |
and e_closed [simp]: "e \<in> D" |
|
249 |
and f_closed [simp]: "[| x \<in> D; y \<in> D |] ==> x \<cdot> y \<in> D" |
|
13936 | 250 |
|
251 |
lemma (in ACeD) left_commute: |
|
14750 | 252 |
"[| x \<in> D; y \<in> D; z \<in> D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)" |
13936 | 253 |
proof - |
14750 | 254 |
assume D: "x \<in> D" "y \<in> D" "z \<in> D" |
13936 | 255 |
then have "x \<cdot> (y \<cdot> z) = (y \<cdot> z) \<cdot> x" by (simp add: commute) |
256 |
also from D have "... = y \<cdot> (z \<cdot> x)" by (simp add: assoc) |
|
257 |
also from D have "z \<cdot> x = x \<cdot> z" by (simp add: commute) |
|
258 |
finally show ?thesis . |
|
259 |
qed |
|
260 |
||
261 |
lemmas (in ACeD) AC = assoc commute left_commute |
|
262 |
||
14750 | 263 |
lemma (in ACeD) left_ident [simp]: "x \<in> D ==> e \<cdot> x = x" |
13936 | 264 |
proof - |
23350 | 265 |
assume "x \<in> D" |
266 |
then have "x \<cdot> e = x" by (rule ident) |
|
267 |
with `x \<in> D` show ?thesis by (simp add: commute) |
|
13936 | 268 |
qed |
269 |
||
270 |
lemma (in ACeD) foldD_Un_Int: |
|
14750 | 271 |
"[| finite A; finite B; A \<subseteq> D; B \<subseteq> D |] ==> |
13936 | 272 |
foldD D f e A \<cdot> foldD D f e B = |
273 |
foldD D f e (A Un B) \<cdot> foldD D f e (A Int B)" |
|
22265 | 274 |
apply (induct set: finite) |
13936 | 275 |
apply (simp add: left_commute LCD.foldD_closed [OF LCD.intro [of D]]) |
276 |
apply (simp add: AC insert_absorb Int_insert_left |
|
277 |
LCD.foldD_insert [OF LCD.intro [of D]] |
|
278 |
LCD.foldD_closed [OF LCD.intro [of D]] |
|
279 |
Int_mono2 Un_subset_iff) |
|
280 |
done |
|
281 |
||
282 |
lemma (in ACeD) foldD_Un_disjoint: |
|
14750 | 283 |
"[| finite A; finite B; A Int B = {}; A \<subseteq> D; B \<subseteq> D |] ==> |
13936 | 284 |
foldD D f e (A Un B) = foldD D f e A \<cdot> foldD D f e B" |
285 |
by (simp add: foldD_Un_Int |
|
286 |
left_commute LCD.foldD_closed [OF LCD.intro [of D]] Un_subset_iff) |
|
287 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
16638
diff
changeset
|
288 |
|
13936 | 289 |
subsection {* Products over Finite Sets *} |
290 |
||
14651 | 291 |
constdefs (structure G) |
15095
63f5f4c265dd
Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents:
14750
diff
changeset
|
292 |
finprod :: "[('b, 'm) monoid_scheme, 'a => 'b, 'a set] => 'b" |
13936 | 293 |
"finprod G f A == if finite A |
14651 | 294 |
then foldD (carrier G) (mult G o f) \<one> A |
13936 | 295 |
else arbitrary" |
296 |
||
14651 | 297 |
syntax |
298 |
"_finprod" :: "index => idt => 'a set => 'b => 'b" |
|
14666 | 299 |
("(3\<Otimes>__:_. _)" [1000, 0, 51, 10] 10) |
14651 | 300 |
syntax (xsymbols) |
301 |
"_finprod" :: "index => idt => 'a set => 'b => 'b" |
|
14666 | 302 |
("(3\<Otimes>__\<in>_. _)" [1000, 0, 51, 10] 10) |
14651 | 303 |
syntax (HTML output) |
304 |
"_finprod" :: "index => idt => 'a set => 'b => 'b" |
|
14666 | 305 |
("(3\<Otimes>__\<in>_. _)" [1000, 0, 51, 10] 10) |
14651 | 306 |
translations |
15095
63f5f4c265dd
Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents:
14750
diff
changeset
|
307 |
"\<Otimes>\<index>i:A. b" == "finprod \<struct>\<index> (%i. b) A" |
63f5f4c265dd
Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents:
14750
diff
changeset
|
308 |
-- {* Beware of argument permutation! *} |
13936 | 309 |
|
310 |
lemma (in comm_monoid) finprod_empty [simp]: |
|
311 |
"finprod G f {} = \<one>" |
|
312 |
by (simp add: finprod_def) |
|
313 |
||
314 |
declare funcsetI [intro] |
|
315 |
funcset_mem [dest] |
|
316 |
||
317 |
lemma (in comm_monoid) finprod_insert [simp]: |
|
318 |
"[| finite F; a \<notin> F; f \<in> F -> carrier G; f a \<in> carrier G |] ==> |
|
319 |
finprod G f (insert a F) = f a \<otimes> finprod G f F" |
|
320 |
apply (rule trans) |
|
321 |
apply (simp add: finprod_def) |
|
322 |
apply (rule trans) |
|
323 |
apply (rule LCD.foldD_insert [OF LCD.intro [of "insert a F"]]) |
|
324 |
apply simp |
|
325 |
apply (rule m_lcomm) |
|
326 |
apply fast |
|
327 |
apply fast |
|
328 |
apply assumption |
|
329 |
apply (fastsimp intro: m_closed) |
|
330 |
apply simp+ |
|
331 |
apply fast |
|
332 |
apply (auto simp add: finprod_def) |
|
333 |
done |
|
334 |
||
335 |
lemma (in comm_monoid) finprod_one [simp]: |
|
14651 | 336 |
"finite A ==> (\<Otimes>i:A. \<one>) = \<one>" |
22265 | 337 |
proof (induct set: finite) |
13936 | 338 |
case empty show ?case by simp |
339 |
next |
|
15328 | 340 |
case (insert a A) |
13936 | 341 |
have "(%i. \<one>) \<in> A -> carrier G" by auto |
342 |
with insert show ?case by simp |
|
343 |
qed |
|
344 |
||
345 |
lemma (in comm_monoid) finprod_closed [simp]: |
|
346 |
fixes A |
|
347 |
assumes fin: "finite A" and f: "f \<in> A -> carrier G" |
|
348 |
shows "finprod G f A \<in> carrier G" |
|
349 |
using fin f |
|
350 |
proof induct |
|
351 |
case empty show ?case by simp |
|
352 |
next |
|
15328 | 353 |
case (insert a A) |
13936 | 354 |
then have a: "f a \<in> carrier G" by fast |
355 |
from insert have A: "f \<in> A -> carrier G" by fast |
|
356 |
from insert A a show ?case by simp |
|
357 |
qed |
|
358 |
||
359 |
lemma funcset_Int_left [simp, intro]: |
|
360 |
"[| f \<in> A -> C; f \<in> B -> C |] ==> f \<in> A Int B -> C" |
|
361 |
by fast |
|
362 |
||
363 |
lemma funcset_Un_left [iff]: |
|
364 |
"(f \<in> A Un B -> C) = (f \<in> A -> C & f \<in> B -> C)" |
|
365 |
by fast |
|
366 |
||
367 |
lemma (in comm_monoid) finprod_Un_Int: |
|
368 |
"[| finite A; finite B; g \<in> A -> carrier G; g \<in> B -> carrier G |] ==> |
|
369 |
finprod G g (A Un B) \<otimes> finprod G g (A Int B) = |
|
370 |
finprod G g A \<otimes> finprod G g B" |
|
371 |
-- {* The reversed orientation looks more natural, but LOOPS as a simprule! *} |
|
22265 | 372 |
proof (induct set: finite) |
13936 | 373 |
case empty then show ?case by (simp add: finprod_closed) |
374 |
next |
|
15328 | 375 |
case (insert a A) |
13936 | 376 |
then have a: "g a \<in> carrier G" by fast |
377 |
from insert have A: "g \<in> A -> carrier G" by fast |
|
378 |
from insert A a show ?case |
|
379 |
by (simp add: m_ac Int_insert_left insert_absorb finprod_closed |
|
380 |
Int_mono2 Un_subset_iff) |
|
381 |
qed |
|
382 |
||
383 |
lemma (in comm_monoid) finprod_Un_disjoint: |
|
384 |
"[| finite A; finite B; A Int B = {}; |
|
385 |
g \<in> A -> carrier G; g \<in> B -> carrier G |] |
|
386 |
==> finprod G g (A Un B) = finprod G g A \<otimes> finprod G g B" |
|
387 |
apply (subst finprod_Un_Int [symmetric]) |
|
388 |
apply (auto simp add: finprod_closed) |
|
389 |
done |
|
390 |
||
391 |
lemma (in comm_monoid) finprod_multf: |
|
392 |
"[| finite A; f \<in> A -> carrier G; g \<in> A -> carrier G |] ==> |
|
393 |
finprod G (%x. f x \<otimes> g x) A = (finprod G f A \<otimes> finprod G g A)" |
|
22265 | 394 |
proof (induct set: finite) |
13936 | 395 |
case empty show ?case by simp |
396 |
next |
|
15328 | 397 |
case (insert a A) then |
14750 | 398 |
have fA: "f \<in> A -> carrier G" by fast |
399 |
from insert have fa: "f a \<in> carrier G" by fast |
|
400 |
from insert have gA: "g \<in> A -> carrier G" by fast |
|
401 |
from insert have ga: "g a \<in> carrier G" by fast |
|
402 |
from insert have fgA: "(%x. f x \<otimes> g x) \<in> A -> carrier G" |
|
13936 | 403 |
by (simp add: Pi_def) |
15095
63f5f4c265dd
Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents:
14750
diff
changeset
|
404 |
show ?case |
63f5f4c265dd
Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents:
14750
diff
changeset
|
405 |
by (simp add: insert fA fa gA ga fgA m_ac) |
13936 | 406 |
qed |
407 |
||
408 |
lemma (in comm_monoid) finprod_cong': |
|
14750 | 409 |
"[| A = B; g \<in> B -> carrier G; |
410 |
!!i. i \<in> B ==> f i = g i |] ==> finprod G f A = finprod G g B" |
|
13936 | 411 |
proof - |
14750 | 412 |
assume prems: "A = B" "g \<in> B -> carrier G" |
413 |
"!!i. i \<in> B ==> f i = g i" |
|
13936 | 414 |
show ?thesis |
415 |
proof (cases "finite B") |
|
416 |
case True |
|
14750 | 417 |
then have "!!A. [| A = B; g \<in> B -> carrier G; |
418 |
!!i. i \<in> B ==> f i = g i |] ==> finprod G f A = finprod G g B" |
|
13936 | 419 |
proof induct |
420 |
case empty thus ?case by simp |
|
421 |
next |
|
15328 | 422 |
case (insert x B) |
13936 | 423 |
then have "finprod G f A = finprod G f (insert x B)" by simp |
424 |
also from insert have "... = f x \<otimes> finprod G f B" |
|
425 |
proof (intro finprod_insert) |
|
23350 | 426 |
show "finite B" by fact |
13936 | 427 |
next |
23350 | 428 |
show "x ~: B" by fact |
13936 | 429 |
next |
430 |
assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i" |
|
431 |
"g \<in> insert x B \<rightarrow> carrier G" |
|
14750 | 432 |
thus "f \<in> B -> carrier G" by fastsimp |
13936 | 433 |
next |
434 |
assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i" |
|
435 |
"g \<in> insert x B \<rightarrow> carrier G" |
|
436 |
thus "f x \<in> carrier G" by fastsimp |
|
437 |
qed |
|
438 |
also from insert have "... = g x \<otimes> finprod G g B" by fastsimp |
|
439 |
also from insert have "... = finprod G g (insert x B)" |
|
440 |
by (intro finprod_insert [THEN sym]) auto |
|
441 |
finally show ?case . |
|
442 |
qed |
|
443 |
with prems show ?thesis by simp |
|
444 |
next |
|
445 |
case False with prems show ?thesis by (simp add: finprod_def) |
|
446 |
qed |
|
447 |
qed |
|
448 |
||
449 |
lemma (in comm_monoid) finprod_cong: |
|
14750 | 450 |
"[| A = B; f \<in> B -> carrier G = True; |
451 |
!!i. i \<in> B ==> f i = g i |] ==> finprod G f A = finprod G g B" |
|
14213
7bf882b0a51e
Changed order of prems in finprod_cong. Slight speedup.
ballarin
parents:
13936
diff
changeset
|
452 |
(* This order of prems is slightly faster (3%) than the last two swapped. *) |
7bf882b0a51e
Changed order of prems in finprod_cong. Slight speedup.
ballarin
parents:
13936
diff
changeset
|
453 |
by (rule finprod_cong') force+ |
13936 | 454 |
|
455 |
text {*Usually, if this rule causes a failed congruence proof error, |
|
14750 | 456 |
the reason is that the premise @{text "g \<in> B -> carrier G"} cannot be shown. |
13936 | 457 |
Adding @{thm [source] Pi_def} to the simpset is often useful. |
458 |
For this reason, @{thm [source] comm_monoid.finprod_cong} |
|
459 |
is not added to the simpset by default. |
|
460 |
*} |
|
461 |
||
462 |
declare funcsetI [rule del] |
|
463 |
funcset_mem [rule del] |
|
464 |
||
465 |
lemma (in comm_monoid) finprod_0 [simp]: |
|
14750 | 466 |
"f \<in> {0::nat} -> carrier G ==> finprod G f {..0} = f 0" |
13936 | 467 |
by (simp add: Pi_def) |
468 |
||
469 |
lemma (in comm_monoid) finprod_Suc [simp]: |
|
14750 | 470 |
"f \<in> {..Suc n} -> carrier G ==> |
13936 | 471 |
finprod G f {..Suc n} = (f (Suc n) \<otimes> finprod G f {..n})" |
472 |
by (simp add: Pi_def atMost_Suc) |
|
473 |
||
474 |
lemma (in comm_monoid) finprod_Suc2: |
|
14750 | 475 |
"f \<in> {..Suc n} -> carrier G ==> |
13936 | 476 |
finprod G f {..Suc n} = (finprod G (%i. f (Suc i)) {..n} \<otimes> f 0)" |
477 |
proof (induct n) |
|
478 |
case 0 thus ?case by (simp add: Pi_def) |
|
479 |
next |
|
480 |
case Suc thus ?case by (simp add: m_assoc Pi_def) |
|
481 |
qed |
|
482 |
||
483 |
lemma (in comm_monoid) finprod_mult [simp]: |
|
14750 | 484 |
"[| f \<in> {..n} -> carrier G; g \<in> {..n} -> carrier G |] ==> |
13936 | 485 |
finprod G (%i. f i \<otimes> g i) {..n::nat} = |
486 |
finprod G f {..n} \<otimes> finprod G g {..n}" |
|
487 |
by (induct n) (simp_all add: m_ac Pi_def) |
|
488 |
||
489 |
end |
|
490 |