1206 constdefs |
1206 constdefs |
1207 setprod :: "('a => 'b) => 'a set => 'b::comm_monoid_mult" |
1207 setprod :: "('a => 'b) => 'a set => 'b::comm_monoid_mult" |
1208 "setprod f A == if finite A then fold (op *) f 1 A else 1" |
1208 "setprod f A == if finite A then fold (op *) f 1 A else 1" |
1209 |
1209 |
1210 syntax |
1210 syntax |
1211 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_:_. _)" [0, 51, 10] 10) |
1211 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3PROD _:_. _)" [0, 51, 10] 10) |
1212 |
|
1213 syntax (xsymbols) |
1212 syntax (xsymbols) |
1214 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
1213 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
1215 syntax (HTML output) |
1214 syntax (HTML output) |
1216 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
1215 "_setprod" :: "idt => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
|
1216 |
|
1217 translations -- {* Beware of argument permutation! *} |
|
1218 "PROD i:A. b" == "setprod (%i. b) A" |
|
1219 "\<Prod>i\<in>A. b" == "setprod (%i. b) A" |
|
1220 |
|
1221 text{* Instead of @{term"\<Prod>x\<in>{x. P}. e"} we introduce the shorter |
|
1222 @{text"\<Prod>x|P. e"}. *} |
|
1223 |
|
1224 syntax |
|
1225 "_qsetprod" :: "idt \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3PROD _ |/ _./ _)" [0,0,10] 10) |
|
1226 syntax (xsymbols) |
|
1227 "_qsetprod" :: "idt \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
|
1228 syntax (HTML output) |
|
1229 "_qsetprod" :: "idt \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
|
1230 |
1217 translations |
1231 translations |
1218 "\<Prod>i:A. b" == "setprod (%i. b) A" -- {* Beware of argument permutation! *} |
1232 "PROD x|P. t" => "setprod (%x. t) {x. P}" |
|
1233 "\<Prod>x|P. t" => "setprod (%x. t) {x. P}" |
|
1234 |
|
1235 text{* Finally we abbreviate @{term"\<Prod>x\<in>A. x"} by @{text"\<Prod>A"}. *} |
1219 |
1236 |
1220 syntax |
1237 syntax |
1221 "_Setprod" :: "'a set => 'a::comm_monoid_mult" ("\<Prod>_" [1000] 999) |
1238 "_Setprod" :: "'a set => 'a::comm_monoid_mult" ("\<Prod>_" [1000] 999) |
1222 |
1239 |
1223 parse_translation {* |
1240 parse_translation {* |
1294 apply (frule setprod_UN_disjoint [of C id f]) |
1311 apply (frule setprod_UN_disjoint [of C id f]) |
1295 apply (unfold Union_def id_def, assumption+) |
1312 apply (unfold Union_def id_def, assumption+) |
1296 done |
1313 done |
1297 |
1314 |
1298 lemma setprod_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
1315 lemma setprod_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
1299 (\<Prod>x:A. (\<Prod>y: B x. f x y)) = |
1316 (\<Prod>x\<in>A. (\<Prod>y\<in> B x. f x y)) = |
1300 (\<Prod>z:(SIGMA x:A. B x). f (fst z) (snd z))" |
1317 (\<Prod>z\<in>(SIGMA x:A. B x). f (fst z) (snd z))" |
1301 by(simp add:setprod_def AC_mult.fold_Sigma split_def cong:setprod_cong) |
1318 by(simp add:setprod_def AC_mult.fold_Sigma split_def cong:setprod_cong) |
1302 |
1319 |
1303 text{*Here we can eliminate the finiteness assumptions, by cases.*} |
1320 text{*Here we can eliminate the finiteness assumptions, by cases.*} |
1304 lemma setprod_cartesian_product: |
1321 lemma setprod_cartesian_product: |
1305 "(\<Prod>x:A. (\<Prod>y: B. f x y)) = (\<Prod>z:(A <*> B). f (fst z) (snd z))" |
1322 "(\<Prod>x\<in>A. (\<Prod>y\<in> B. f x y)) = (\<Prod>z\<in>(A <*> B). f (fst z) (snd z))" |
1306 apply (cases "finite A") |
1323 apply (cases "finite A") |
1307 apply (cases "finite B") |
1324 apply (cases "finite B") |
1308 apply (simp add: setprod_Sigma) |
1325 apply (simp add: setprod_Sigma) |
1309 apply (cases "A={}", simp) |
1326 apply (cases "A={}", simp) |
1310 apply (simp add: setprod_1) |
1327 apply (simp add: setprod_1) |
1538 apply (erule finite_induct) |
1555 apply (erule finite_induct) |
1539 apply (auto simp add: ring_distrib add_ac) |
1556 apply (auto simp add: ring_distrib add_ac) |
1540 done |
1557 done |
1541 |
1558 |
1542 |
1559 |
1543 lemma setprod_constant: "finite A ==> (\<Prod>x: A. (y::'a::recpower)) = y^(card A)" |
1560 lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::recpower)) = y^(card A)" |
1544 apply (erule finite_induct) |
1561 apply (erule finite_induct) |
1545 apply (auto simp add: power_Suc) |
1562 apply (auto simp add: power_Suc) |
1546 done |
1563 done |
1547 |
1564 |
1548 lemma setsum_bounded: |
1565 lemma setsum_bounded: |