author | wenzelm |
Mon, 03 Oct 2016 21:36:10 +0200 | |
changeset 64027 | 4a33d740c9dc |
parent 63952 | 354808e9f44b |
child 64267 | b9a1486e79be |
permissions | -rw-r--r-- |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1 |
(* Title: HOL/Groups_Big.thy |
63654 | 2 |
Author: Tobias Nipkow |
3 |
Author: Lawrence C Paulson |
|
4 |
Author: Markus Wenzel |
|
5 |
Author: Jeremy Avigad |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
6 |
*) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
7 |
|
60758 | 8 |
section \<open>Big sum and product over finite (non-empty) sets\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
9 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
10 |
theory Groups_Big |
63654 | 11 |
imports Finite_Set Power |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
12 |
begin |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
13 |
|
60758 | 14 |
subsection \<open>Generic monoid operation over a set\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
15 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
16 |
locale comm_monoid_set = comm_monoid |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
17 |
begin |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
18 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
19 |
interpretation comp_fun_commute f |
61169 | 20 |
by standard (simp add: fun_eq_iff left_commute) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
21 |
|
54745 | 22 |
interpretation comp?: comp_fun_commute "f \<circ> g" |
23 |
by (fact comp_comp_fun_commute) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
24 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
25 |
definition F :: "('b \<Rightarrow> 'a) \<Rightarrow> 'b set \<Rightarrow> 'a" |
63654 | 26 |
where eq_fold: "F g A = Finite_Set.fold (f \<circ> g) \<^bold>1 A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
27 |
|
63654 | 28 |
lemma infinite [simp]: "\<not> finite A \<Longrightarrow> F g A = \<^bold>1" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
29 |
by (simp add: eq_fold) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
30 |
|
63654 | 31 |
lemma empty [simp]: "F g {} = \<^bold>1" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
32 |
by (simp add: eq_fold) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
33 |
|
63654 | 34 |
lemma insert [simp]: "finite A \<Longrightarrow> x \<notin> A \<Longrightarrow> F g (insert x A) = g x \<^bold>* F g A" |
35 |
by (simp add: eq_fold) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
36 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
37 |
lemma remove: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
38 |
assumes "finite A" and "x \<in> A" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
39 |
shows "F g A = g x \<^bold>* F g (A - {x})" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
40 |
proof - |
63654 | 41 |
from \<open>x \<in> A\<close> obtain B where B: "A = insert x B" and "x \<notin> B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
42 |
by (auto dest: mk_disjoint_insert) |
63654 | 43 |
moreover from \<open>finite A\<close> B have "finite B" by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
44 |
ultimately show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
45 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
46 |
|
63654 | 47 |
lemma insert_remove: "finite A \<Longrightarrow> F g (insert x A) = g x \<^bold>* F g (A - {x})" |
48 |
by (cases "x \<in> A") (simp_all add: remove insert_absorb) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
49 |
|
63952
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
50 |
lemma insert_if: "finite A \<Longrightarrow> F g (insert x A) = (if x \<in> A then F g A else g x \<^bold>* F g A)" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
51 |
by (cases "x \<in> A") (simp_all add: insert_absorb) |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
52 |
|
63654 | 53 |
lemma neutral: "\<forall>x\<in>A. g x = \<^bold>1 \<Longrightarrow> F g A = \<^bold>1" |
54 |
by (induct A rule: infinite_finite_induct) simp_all |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
55 |
|
63654 | 56 |
lemma neutral_const [simp]: "F (\<lambda>_. \<^bold>1) A = \<^bold>1" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
57 |
by (simp add: neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
58 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
59 |
lemma union_inter: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
60 |
assumes "finite A" and "finite B" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
61 |
shows "F g (A \<union> B) \<^bold>* F g (A \<inter> B) = F g A \<^bold>* F g B" |
61799 | 62 |
\<comment> \<open>The reversed orientation looks more natural, but LOOPS as a simprule!\<close> |
63654 | 63 |
using assms |
64 |
proof (induct A) |
|
65 |
case empty |
|
66 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
67 |
next |
63654 | 68 |
case (insert x A) |
69 |
then show ?case |
|
70 |
by (auto simp: insert_absorb Int_insert_left commute [of _ "g x"] assoc left_commute) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
71 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
72 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
73 |
corollary union_inter_neutral: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
74 |
assumes "finite A" and "finite B" |
63654 | 75 |
and "\<forall>x \<in> A \<inter> B. g x = \<^bold>1" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
76 |
shows "F g (A \<union> B) = F g A \<^bold>* F g B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
77 |
using assms by (simp add: union_inter [symmetric] neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
78 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
79 |
corollary union_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
80 |
assumes "finite A" and "finite B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
81 |
assumes "A \<inter> B = {}" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
82 |
shows "F g (A \<union> B) = F g A \<^bold>* F g B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
83 |
using assms by (simp add: union_inter_neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
84 |
|
57418 | 85 |
lemma union_diff2: |
86 |
assumes "finite A" and "finite B" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
87 |
shows "F g (A \<union> B) = F g (A - B) \<^bold>* F g (B - A) \<^bold>* F g (A \<inter> B)" |
57418 | 88 |
proof - |
89 |
have "A \<union> B = A - B \<union> (B - A) \<union> A \<inter> B" |
|
90 |
by auto |
|
63654 | 91 |
with assms show ?thesis |
92 |
by simp (subst union_disjoint, auto)+ |
|
57418 | 93 |
qed |
94 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
95 |
lemma subset_diff: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
96 |
assumes "B \<subseteq> A" and "finite A" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
97 |
shows "F g A = F g (A - B) \<^bold>* F g B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
98 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
99 |
from assms have "finite (A - B)" by auto |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
100 |
moreover from assms have "finite B" by (rule finite_subset) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
101 |
moreover from assms have "(A - B) \<inter> B = {}" by auto |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
102 |
ultimately have "F g (A - B \<union> B) = F g (A - B) \<^bold>* F g B" by (rule union_disjoint) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
103 |
moreover from assms have "A \<union> B = A" by auto |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
104 |
ultimately show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
105 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
106 |
|
56545 | 107 |
lemma setdiff_irrelevant: |
108 |
assumes "finite A" |
|
109 |
shows "F g (A - {x. g x = z}) = F g A" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
110 |
using assms by (induct A) (simp_all add: insert_Diff_if) |
58195 | 111 |
|
56545 | 112 |
lemma not_neutral_contains_not_neutral: |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
113 |
assumes "F g A \<noteq> \<^bold>1" |
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
114 |
obtains a where "a \<in> A" and "g a \<noteq> \<^bold>1" |
56545 | 115 |
proof - |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
116 |
from assms have "\<exists>a\<in>A. g a \<noteq> \<^bold>1" |
56545 | 117 |
proof (induct A rule: infinite_finite_induct) |
63654 | 118 |
case infinite |
119 |
then show ?case by simp |
|
120 |
next |
|
121 |
case empty |
|
122 |
then show ?case by simp |
|
123 |
next |
|
56545 | 124 |
case (insert a A) |
63654 | 125 |
then show ?case by fastforce |
126 |
qed |
|
56545 | 127 |
with that show thesis by blast |
128 |
qed |
|
129 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
130 |
lemma reindex: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
131 |
assumes "inj_on h A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
132 |
shows "F g (h ` A) = F (g \<circ> h) A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
133 |
proof (cases "finite A") |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
134 |
case True |
63654 | 135 |
with assms show ?thesis |
136 |
by (simp add: eq_fold fold_image comp_assoc) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
137 |
next |
63654 | 138 |
case False |
139 |
with assms have "\<not> finite (h ` A)" by (blast dest: finite_imageD) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
140 |
with False show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
141 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
142 |
|
63357 | 143 |
lemma cong [fundef_cong]: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
144 |
assumes "A = B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
145 |
assumes g_h: "\<And>x. x \<in> B \<Longrightarrow> g x = h x" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
146 |
shows "F g A = F h B" |
60758 | 147 |
using g_h unfolding \<open>A = B\<close> |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
148 |
by (induct B rule: infinite_finite_induct) auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
149 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
150 |
lemma strong_cong [cong]: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
151 |
assumes "A = B" "\<And>x. x \<in> B =simp=> g x = h x" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
152 |
shows "F (\<lambda>x. g x) A = F (\<lambda>x. h x) B" |
63654 | 153 |
by (rule cong) (use assms in \<open>simp_all add: simp_implies_def\<close>) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
154 |
|
57418 | 155 |
lemma reindex_cong: |
156 |
assumes "inj_on l B" |
|
157 |
assumes "A = l ` B" |
|
158 |
assumes "\<And>x. x \<in> B \<Longrightarrow> g (l x) = h x" |
|
159 |
shows "F g A = F h B" |
|
160 |
using assms by (simp add: reindex) |
|
161 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
162 |
lemma UNION_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
163 |
assumes "finite I" and "\<forall>i\<in>I. finite (A i)" |
63654 | 164 |
and "\<forall>i\<in>I. \<forall>j\<in>I. i \<noteq> j \<longrightarrow> A i \<inter> A j = {}" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
165 |
shows "F g (UNION I A) = F (\<lambda>x. F g (A x)) I" |
63654 | 166 |
apply (insert assms) |
167 |
apply (induct rule: finite_induct) |
|
168 |
apply simp |
|
169 |
apply atomize |
|
170 |
apply (subgoal_tac "\<forall>i\<in>Fa. x \<noteq> i") |
|
171 |
prefer 2 apply blast |
|
172 |
apply (subgoal_tac "A x \<inter> UNION Fa A = {}") |
|
173 |
prefer 2 apply blast |
|
174 |
apply (simp add: union_disjoint) |
|
175 |
done |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
176 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
177 |
lemma Union_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
178 |
assumes "\<forall>A\<in>C. finite A" "\<forall>A\<in>C. \<forall>B\<in>C. A \<noteq> B \<longrightarrow> A \<inter> B = {}" |
61952 | 179 |
shows "F g (\<Union>C) = (F \<circ> F) g C" |
63654 | 180 |
proof (cases "finite C") |
181 |
case True |
|
182 |
from UNION_disjoint [OF this assms] show ?thesis by simp |
|
183 |
next |
|
184 |
case False |
|
185 |
then show ?thesis by (auto dest: finite_UnionD intro: infinite) |
|
186 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
187 |
|
63654 | 188 |
lemma distrib: "F (\<lambda>x. g x \<^bold>* h x) A = F g A \<^bold>* F h A" |
63092 | 189 |
by (induct A rule: infinite_finite_induct) (simp_all add: assoc commute left_commute) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
190 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
191 |
lemma Sigma: |
61032
b57df8eecad6
standardized some occurences of ancient "split" alias
haftmann
parents:
60974
diff
changeset
|
192 |
"finite A \<Longrightarrow> \<forall>x\<in>A. finite (B x) \<Longrightarrow> F (\<lambda>x. F (g x) (B x)) A = F (case_prod g) (SIGMA x:A. B x)" |
63654 | 193 |
apply (subst Sigma_def) |
194 |
apply (subst UNION_disjoint) |
|
195 |
apply assumption |
|
196 |
apply simp |
|
197 |
apply blast |
|
198 |
apply (rule cong) |
|
199 |
apply rule |
|
200 |
apply (simp add: fun_eq_iff) |
|
201 |
apply (subst UNION_disjoint) |
|
202 |
apply simp |
|
203 |
apply simp |
|
204 |
apply blast |
|
205 |
apply (simp add: comp_def) |
|
206 |
done |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
207 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
208 |
lemma related: |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
209 |
assumes Re: "R \<^bold>1 \<^bold>1" |
63654 | 210 |
and Rop: "\<forall>x1 y1 x2 y2. R x1 x2 \<and> R y1 y2 \<longrightarrow> R (x1 \<^bold>* y1) (x2 \<^bold>* y2)" |
211 |
and fin: "finite S" |
|
212 |
and R_h_g: "\<forall>x\<in>S. R (h x) (g x)" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
213 |
shows "R (F h S) (F g S)" |
63654 | 214 |
using fin by (rule finite_subset_induct) (use assms in auto) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
215 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
216 |
lemma mono_neutral_cong_left: |
63654 | 217 |
assumes "finite T" |
218 |
and "S \<subseteq> T" |
|
219 |
and "\<forall>i \<in> T - S. h i = \<^bold>1" |
|
220 |
and "\<And>x. x \<in> S \<Longrightarrow> g x = h x" |
|
221 |
shows "F g S = F h T" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
222 |
proof- |
60758 | 223 |
have eq: "T = S \<union> (T - S)" using \<open>S \<subseteq> T\<close> by blast |
224 |
have d: "S \<inter> (T - S) = {}" using \<open>S \<subseteq> T\<close> by blast |
|
225 |
from \<open>finite T\<close> \<open>S \<subseteq> T\<close> have f: "finite S" "finite (T - S)" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
226 |
by (auto intro: finite_subset) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
227 |
show ?thesis using assms(4) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
228 |
by (simp add: union_disjoint [OF f d, unfolded eq [symmetric]] neutral [OF assms(3)]) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
229 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
230 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
231 |
lemma mono_neutral_cong_right: |
63654 | 232 |
"finite T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. g i = \<^bold>1 \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> g x = h x) \<Longrightarrow> |
233 |
F g T = F h S" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
234 |
by (auto intro!: mono_neutral_cong_left [symmetric]) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
235 |
|
63654 | 236 |
lemma mono_neutral_left: "finite T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. g i = \<^bold>1 \<Longrightarrow> F g S = F g T" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
237 |
by (blast intro: mono_neutral_cong_left) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
238 |
|
63654 | 239 |
lemma mono_neutral_right: "finite T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. g i = \<^bold>1 \<Longrightarrow> F g T = F g S" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
240 |
by (blast intro!: mono_neutral_left [symmetric]) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
241 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
242 |
lemma reindex_bij_betw: "bij_betw h S T \<Longrightarrow> F (\<lambda>x. g (h x)) S = F g T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
243 |
by (auto simp: bij_betw_def reindex) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
244 |
|
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
245 |
lemma reindex_bij_witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
246 |
assumes witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
247 |
"\<And>a. a \<in> S \<Longrightarrow> i (j a) = a" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
248 |
"\<And>a. a \<in> S \<Longrightarrow> j a \<in> T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
249 |
"\<And>b. b \<in> T \<Longrightarrow> j (i b) = b" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
250 |
"\<And>b. b \<in> T \<Longrightarrow> i b \<in> S" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
251 |
assumes eq: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
252 |
"\<And>a. a \<in> S \<Longrightarrow> h (j a) = g a" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
253 |
shows "F g S = F h T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
254 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
255 |
have "bij_betw j S T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
256 |
using bij_betw_byWitness[where A=S and f=j and f'=i and A'=T] witness by auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
257 |
moreover have "F g S = F (\<lambda>x. h (j x)) S" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
258 |
by (intro cong) (auto simp: eq) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
259 |
ultimately show ?thesis |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
260 |
by (simp add: reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
261 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
262 |
|
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
263 |
lemma reindex_bij_betw_not_neutral: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
264 |
assumes fin: "finite S'" "finite T'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
265 |
assumes bij: "bij_betw h (S - S') (T - T')" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
266 |
assumes nn: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
267 |
"\<And>a. a \<in> S' \<Longrightarrow> g (h a) = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
268 |
"\<And>b. b \<in> T' \<Longrightarrow> g b = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
269 |
shows "F (\<lambda>x. g (h x)) S = F g T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
270 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
271 |
have [simp]: "finite S \<longleftrightarrow> finite T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
272 |
using bij_betw_finite[OF bij] fin by auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
273 |
show ?thesis |
63654 | 274 |
proof (cases "finite S") |
275 |
case True |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
276 |
with nn have "F (\<lambda>x. g (h x)) S = F (\<lambda>x. g (h x)) (S - S')" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
277 |
by (intro mono_neutral_cong_right) auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
278 |
also have "\<dots> = F g (T - T')" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
279 |
using bij by (rule reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
280 |
also have "\<dots> = F g T" |
60758 | 281 |
using nn \<open>finite S\<close> by (intro mono_neutral_cong_left) auto |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
282 |
finally show ?thesis . |
63654 | 283 |
next |
284 |
case False |
|
285 |
then show ?thesis by simp |
|
286 |
qed |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
287 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
288 |
|
57418 | 289 |
lemma reindex_nontrivial: |
290 |
assumes "finite A" |
|
63654 | 291 |
and nz: "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x \<noteq> y \<Longrightarrow> h x = h y \<Longrightarrow> g (h x) = \<^bold>1" |
57418 | 292 |
shows "F g (h ` A) = F (g \<circ> h) A" |
293 |
proof (subst reindex_bij_betw_not_neutral [symmetric]) |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
294 |
show "bij_betw h (A - {x \<in> A. (g \<circ> h) x = \<^bold>1}) (h ` A - h ` {x \<in> A. (g \<circ> h) x = \<^bold>1})" |
57418 | 295 |
using nz by (auto intro!: inj_onI simp: bij_betw_def) |
63654 | 296 |
qed (use \<open>finite A\<close> in auto) |
57418 | 297 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
298 |
lemma reindex_bij_witness_not_neutral: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
299 |
assumes fin: "finite S'" "finite T'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
300 |
assumes witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
301 |
"\<And>a. a \<in> S - S' \<Longrightarrow> i (j a) = a" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
302 |
"\<And>a. a \<in> S - S' \<Longrightarrow> j a \<in> T - T'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
303 |
"\<And>b. b \<in> T - T' \<Longrightarrow> j (i b) = b" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
304 |
"\<And>b. b \<in> T - T' \<Longrightarrow> i b \<in> S - S'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
305 |
assumes nn: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
306 |
"\<And>a. a \<in> S' \<Longrightarrow> g a = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
307 |
"\<And>b. b \<in> T' \<Longrightarrow> h b = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
308 |
assumes eq: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
309 |
"\<And>a. a \<in> S \<Longrightarrow> h (j a) = g a" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
310 |
shows "F g S = F h T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
311 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
312 |
have bij: "bij_betw j (S - (S' \<inter> S)) (T - (T' \<inter> T))" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
313 |
using witness by (intro bij_betw_byWitness[where f'=i]) auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
314 |
have F_eq: "F g S = F (\<lambda>x. h (j x)) S" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
315 |
by (intro cong) (auto simp: eq) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
316 |
show ?thesis |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
317 |
unfolding F_eq using fin nn eq |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
318 |
by (intro reindex_bij_betw_not_neutral[OF _ _ bij]) auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
319 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
320 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
321 |
lemma delta: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
322 |
assumes fS: "finite S" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
323 |
shows "F (\<lambda>k. if k = a then b k else \<^bold>1) S = (if a \<in> S then b a else \<^bold>1)" |
63654 | 324 |
proof - |
325 |
let ?f = "(\<lambda>k. if k = a then b k else \<^bold>1)" |
|
326 |
show ?thesis |
|
327 |
proof (cases "a \<in> S") |
|
328 |
case False |
|
329 |
then have "\<forall>k\<in>S. ?f k = \<^bold>1" by simp |
|
330 |
with False show ?thesis by simp |
|
331 |
next |
|
332 |
case True |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
333 |
let ?A = "S - {a}" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
334 |
let ?B = "{a}" |
63654 | 335 |
from True have eq: "S = ?A \<union> ?B" by blast |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
336 |
have dj: "?A \<inter> ?B = {}" by simp |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
337 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
338 |
have "F ?f S = F ?f ?A \<^bold>* F ?f ?B" |
63654 | 339 |
using union_disjoint [OF fAB dj, of ?f, unfolded eq [symmetric]] by simp |
340 |
with True show ?thesis by simp |
|
341 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
342 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
343 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
344 |
lemma delta': |
63654 | 345 |
assumes fin: "finite S" |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
346 |
shows "F (\<lambda>k. if a = k then b k else \<^bold>1) S = (if a \<in> S then b a else \<^bold>1)" |
63654 | 347 |
using delta [OF fin, of a b, symmetric] by (auto intro: cong) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
348 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
349 |
lemma If_cases: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
350 |
fixes P :: "'b \<Rightarrow> bool" and g h :: "'b \<Rightarrow> 'a" |
63654 | 351 |
assumes fin: "finite A" |
352 |
shows "F (\<lambda>x. if P x then h x else g x) A = F h (A \<inter> {x. P x}) \<^bold>* F g (A \<inter> - {x. P x})" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
353 |
proof - |
63654 | 354 |
have a: "A = A \<inter> {x. P x} \<union> A \<inter> -{x. P x}" "(A \<inter> {x. P x}) \<inter> (A \<inter> -{x. P x}) = {}" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
355 |
by blast+ |
63654 | 356 |
from fin have f: "finite (A \<inter> {x. P x})" "finite (A \<inter> -{x. P x})" by auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
357 |
let ?g = "\<lambda>x. if P x then h x else g x" |
63654 | 358 |
from union_disjoint [OF f a(2), of ?g] a(1) show ?thesis |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
359 |
by (subst (1 2) cong) simp_all |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
360 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
361 |
|
63654 | 362 |
lemma cartesian_product: "F (\<lambda>x. F (g x) B) A = F (case_prod g) (A \<times> B)" |
363 |
apply (rule sym) |
|
364 |
apply (cases "finite A") |
|
365 |
apply (cases "finite B") |
|
366 |
apply (simp add: Sigma) |
|
367 |
apply (cases "A = {}") |
|
368 |
apply simp |
|
369 |
apply simp |
|
370 |
apply (auto intro: infinite dest: finite_cartesian_productD2) |
|
371 |
apply (cases "B = {}") |
|
372 |
apply (auto intro: infinite dest: finite_cartesian_productD1) |
|
373 |
done |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
374 |
|
57418 | 375 |
lemma inter_restrict: |
376 |
assumes "finite A" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
377 |
shows "F g (A \<inter> B) = F (\<lambda>x. if x \<in> B then g x else \<^bold>1) A" |
57418 | 378 |
proof - |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
379 |
let ?g = "\<lambda>x. if x \<in> A \<inter> B then g x else \<^bold>1" |
63654 | 380 |
have "\<forall>i\<in>A - A \<inter> B. (if i \<in> A \<inter> B then g i else \<^bold>1) = \<^bold>1" by simp |
57418 | 381 |
moreover have "A \<inter> B \<subseteq> A" by blast |
63654 | 382 |
ultimately have "F ?g (A \<inter> B) = F ?g A" |
383 |
using \<open>finite A\<close> by (intro mono_neutral_left) auto |
|
57418 | 384 |
then show ?thesis by simp |
385 |
qed |
|
386 |
||
387 |
lemma inter_filter: |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
388 |
"finite A \<Longrightarrow> F g {x \<in> A. P x} = F (\<lambda>x. if P x then g x else \<^bold>1) A" |
57418 | 389 |
by (simp add: inter_restrict [symmetric, of A "{x. P x}" g, simplified mem_Collect_eq] Int_def) |
390 |
||
391 |
lemma Union_comp: |
|
392 |
assumes "\<forall>A \<in> B. finite A" |
|
63654 | 393 |
and "\<And>A1 A2 x. A1 \<in> B \<Longrightarrow> A2 \<in> B \<Longrightarrow> A1 \<noteq> A2 \<Longrightarrow> x \<in> A1 \<Longrightarrow> x \<in> A2 \<Longrightarrow> g x = \<^bold>1" |
57418 | 394 |
shows "F g (\<Union>B) = (F \<circ> F) g B" |
63654 | 395 |
using assms |
396 |
proof (induct B rule: infinite_finite_induct) |
|
57418 | 397 |
case (infinite A) |
398 |
then have "\<not> finite (\<Union>A)" by (blast dest: finite_UnionD) |
|
399 |
with infinite show ?case by simp |
|
400 |
next |
|
63654 | 401 |
case empty |
402 |
then show ?case by simp |
|
57418 | 403 |
next |
404 |
case (insert A B) |
|
405 |
then have "finite A" "finite B" "finite (\<Union>B)" "A \<notin> B" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
406 |
and "\<forall>x\<in>A \<inter> \<Union>B. g x = \<^bold>1" |
63654 | 407 |
and H: "F g (\<Union>B) = (F \<circ> F) g B" by auto |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
408 |
then have "F g (A \<union> \<Union>B) = F g A \<^bold>* F g (\<Union>B)" |
57418 | 409 |
by (simp add: union_inter_neutral) |
60758 | 410 |
with \<open>finite B\<close> \<open>A \<notin> B\<close> show ?case |
57418 | 411 |
by (simp add: H) |
412 |
qed |
|
413 |
||
63654 | 414 |
lemma commute: "F (\<lambda>i. F (g i) B) A = F (\<lambda>j. F (\<lambda>i. g i j) A) B" |
57418 | 415 |
unfolding cartesian_product |
416 |
by (rule reindex_bij_witness [where i = "\<lambda>(i, j). (j, i)" and j = "\<lambda>(i, j). (j, i)"]) auto |
|
417 |
||
418 |
lemma commute_restrict: |
|
419 |
"finite A \<Longrightarrow> finite B \<Longrightarrow> |
|
420 |
F (\<lambda>x. F (g x) {y. y \<in> B \<and> R x y}) A = F (\<lambda>y. F (\<lambda>x. g x y) {x. x \<in> A \<and> R x y}) B" |
|
421 |
by (simp add: inter_filter) (rule commute) |
|
422 |
||
423 |
lemma Plus: |
|
424 |
fixes A :: "'b set" and B :: "'c set" |
|
425 |
assumes fin: "finite A" "finite B" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
426 |
shows "F g (A <+> B) = F (g \<circ> Inl) A \<^bold>* F (g \<circ> Inr) B" |
57418 | 427 |
proof - |
428 |
have "A <+> B = Inl ` A \<union> Inr ` B" by auto |
|
63654 | 429 |
moreover from fin have "finite (Inl ` A)" "finite (Inr ` B)" by auto |
430 |
moreover have "Inl ` A \<inter> Inr ` B = {}" by auto |
|
431 |
moreover have "inj_on Inl A" "inj_on Inr B" by (auto intro: inj_onI) |
|
432 |
ultimately show ?thesis |
|
433 |
using fin by (simp add: union_disjoint reindex) |
|
57418 | 434 |
qed |
435 |
||
58195 | 436 |
lemma same_carrier: |
437 |
assumes "finite C" |
|
438 |
assumes subset: "A \<subseteq> C" "B \<subseteq> C" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
439 |
assumes trivial: "\<And>a. a \<in> C - A \<Longrightarrow> g a = \<^bold>1" "\<And>b. b \<in> C - B \<Longrightarrow> h b = \<^bold>1" |
58195 | 440 |
shows "F g A = F h B \<longleftrightarrow> F g C = F h C" |
441 |
proof - |
|
63654 | 442 |
have "finite A" and "finite B" and "finite (C - A)" and "finite (C - B)" |
443 |
using \<open>finite C\<close> subset by (auto elim: finite_subset) |
|
58195 | 444 |
from subset have [simp]: "A - (C - A) = A" by auto |
445 |
from subset have [simp]: "B - (C - B) = B" by auto |
|
446 |
from subset have "C = A \<union> (C - A)" by auto |
|
447 |
then have "F g C = F g (A \<union> (C - A))" by simp |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
448 |
also have "\<dots> = F g (A - (C - A)) \<^bold>* F g (C - A - A) \<^bold>* F g (A \<inter> (C - A))" |
60758 | 449 |
using \<open>finite A\<close> \<open>finite (C - A)\<close> by (simp only: union_diff2) |
63654 | 450 |
finally have *: "F g C = F g A" using trivial by simp |
58195 | 451 |
from subset have "C = B \<union> (C - B)" by auto |
452 |
then have "F h C = F h (B \<union> (C - B))" by simp |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
453 |
also have "\<dots> = F h (B - (C - B)) \<^bold>* F h (C - B - B) \<^bold>* F h (B \<inter> (C - B))" |
60758 | 454 |
using \<open>finite B\<close> \<open>finite (C - B)\<close> by (simp only: union_diff2) |
63654 | 455 |
finally have "F h C = F h B" |
456 |
using trivial by simp |
|
457 |
with * show ?thesis by simp |
|
58195 | 458 |
qed |
459 |
||
460 |
lemma same_carrierI: |
|
461 |
assumes "finite C" |
|
462 |
assumes subset: "A \<subseteq> C" "B \<subseteq> C" |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
463 |
assumes trivial: "\<And>a. a \<in> C - A \<Longrightarrow> g a = \<^bold>1" "\<And>b. b \<in> C - B \<Longrightarrow> h b = \<^bold>1" |
58195 | 464 |
assumes "F g C = F h C" |
465 |
shows "F g A = F h B" |
|
466 |
using assms same_carrier [of C A B] by simp |
|
467 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
468 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
469 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
470 |
|
60758 | 471 |
subsection \<open>Generalized summation over a set\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
472 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
473 |
context comm_monoid_add |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
474 |
begin |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
475 |
|
61605 | 476 |
sublocale setsum: comm_monoid_set plus 0 |
63654 | 477 |
defines setsum = setsum.F .. |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
478 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
479 |
abbreviation Setsum ("\<Sum>_" [1000] 999) |
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
480 |
where "\<Sum>A \<equiv> setsum (\<lambda>x. x) A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
481 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
482 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
483 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
484 |
text \<open>Now: lot's of fancy syntax. First, @{term "setsum (\<lambda>x. e) A"} is written \<open>\<Sum>x\<in>A. e\<close>.\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
485 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
486 |
syntax (ASCII) |
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
487 |
"_setsum" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b::comm_monoid_add" ("(3SUM _:_./ _)" [0, 51, 10] 10) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
488 |
syntax |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
489 |
"_setsum" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b::comm_monoid_add" ("(2\<Sum>_\<in>_./ _)" [0, 51, 10] 10) |
61799 | 490 |
translations \<comment> \<open>Beware of argument permutation!\<close> |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
491 |
"\<Sum>i\<in>A. b" \<rightleftharpoons> "CONST setsum (\<lambda>i. b) A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
492 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
493 |
text \<open>Instead of @{term"\<Sum>x\<in>{x. P}. e"} we introduce the shorter \<open>\<Sum>x|P. e\<close>.\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
494 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
495 |
syntax (ASCII) |
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
496 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3SUM _ |/ _./ _)" [0, 0, 10] 10) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
497 |
syntax |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
498 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(2\<Sum>_ | (_)./ _)" [0, 0, 10] 10) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
499 |
translations |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
500 |
"\<Sum>x|P. t" => "CONST setsum (\<lambda>x. t) {x. P}" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
501 |
|
60758 | 502 |
print_translation \<open> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
503 |
let |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
504 |
fun setsum_tr' [Abs (x, Tx, t), Const (@{const_syntax Collect}, _) $ Abs (y, Ty, P)] = |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
505 |
if x <> y then raise Match |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
506 |
else |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
507 |
let |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
508 |
val x' = Syntax_Trans.mark_bound_body (x, Tx); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
509 |
val t' = subst_bound (x', t); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
510 |
val P' = subst_bound (x', P); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
511 |
in |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
512 |
Syntax.const @{syntax_const "_qsetsum"} $ Syntax_Trans.mark_bound_abs (x, Tx) $ P' $ t' |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
513 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
514 |
| setsum_tr' _ = raise Match; |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
515 |
in [(@{const_syntax setsum}, K setsum_tr')] end |
60758 | 516 |
\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
517 |
|
63654 | 518 |
(* TODO generalization candidates *) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
519 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
520 |
lemma (in comm_monoid_add) setsum_image_gen: |
63654 | 521 |
assumes fin: "finite S" |
57418 | 522 |
shows "setsum g S = setsum (\<lambda>y. setsum g {x. x \<in> S \<and> f x = y}) (f ` S)" |
63654 | 523 |
proof - |
524 |
have "{y. y\<in> f`S \<and> f x = y} = {f x}" if "x \<in> S" for x |
|
525 |
using that by auto |
|
526 |
then have "setsum g S = setsum (\<lambda>x. setsum (\<lambda>y. g x) {y. y\<in> f`S \<and> f x = y}) S" |
|
57418 | 527 |
by simp |
528 |
also have "\<dots> = setsum (\<lambda>y. setsum g {x. x \<in> S \<and> f x = y}) (f ` S)" |
|
63654 | 529 |
by (rule setsum.commute_restrict [OF fin finite_imageI [OF fin]]) |
57418 | 530 |
finally show ?thesis . |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
531 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
532 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
533 |
|
60758 | 534 |
subsubsection \<open>Properties in more restricted classes of structures\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
535 |
|
63654 | 536 |
lemma setsum_Un: |
537 |
"finite A \<Longrightarrow> finite B \<Longrightarrow> setsum f (A \<union> B) = setsum f A + setsum f B - setsum f (A \<inter> B)" |
|
538 |
for f :: "'b \<Rightarrow> 'a::ab_group_add" |
|
539 |
by (subst setsum.union_inter [symmetric]) (auto simp add: algebra_simps) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
540 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
541 |
lemma setsum_Un2: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
542 |
assumes "finite (A \<union> B)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
543 |
shows "setsum f (A \<union> B) = setsum f (A - B) + setsum f (B - A) + setsum f (A \<inter> B)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
544 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
545 |
have "A \<union> B = A - B \<union> (B - A) \<union> A \<inter> B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
546 |
by auto |
63654 | 547 |
with assms show ?thesis |
548 |
by simp (subst setsum.union_disjoint, auto)+ |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
549 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
550 |
|
63654 | 551 |
lemma setsum_diff1: |
552 |
fixes f :: "'b \<Rightarrow> 'a::ab_group_add" |
|
553 |
assumes "finite A" |
|
554 |
shows "setsum f (A - {a}) = (if a \<in> A then setsum f A - f a else setsum f A)" |
|
555 |
using assms by induct (auto simp: insert_Diff_if) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
556 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
557 |
lemma setsum_diff: |
63654 | 558 |
fixes f :: "'b \<Rightarrow> 'a::ab_group_add" |
559 |
assumes "finite A" "B \<subseteq> A" |
|
560 |
shows "setsum f (A - B) = setsum f A - setsum f B" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
561 |
proof - |
63654 | 562 |
from assms(2,1) have "finite B" by (rule finite_subset) |
563 |
from this \<open>B \<subseteq> A\<close> |
|
564 |
show ?thesis |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
565 |
proof induct |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
566 |
case empty |
63654 | 567 |
thus ?case by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
568 |
next |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
569 |
case (insert x F) |
63654 | 570 |
with \<open>finite A\<close> \<open>finite B\<close> show ?case |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
571 |
by (simp add: Diff_insert[where a=x and B=F] setsum_diff1 insert_absorb) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
572 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
573 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
574 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
575 |
lemma (in ordered_comm_monoid_add) setsum_mono: |
63915 | 576 |
"(\<And>i. i\<in>K \<Longrightarrow> f i \<le> g i) \<Longrightarrow> (\<Sum>i\<in>K. f i) \<le> (\<Sum>i\<in>K. g i)" |
577 |
by (induct K rule: infinite_finite_induct) (use add_mono in auto) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
578 |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
579 |
lemma (in strict_ordered_comm_monoid_add) setsum_strict_mono: |
63654 | 580 |
assumes "finite A" "A \<noteq> {}" |
581 |
and "\<And>x. x \<in> A \<Longrightarrow> f x < g x" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
582 |
shows "setsum f A < setsum g A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
583 |
using assms |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
584 |
proof (induct rule: finite_ne_induct) |
63654 | 585 |
case singleton |
586 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
587 |
next |
63654 | 588 |
case insert |
589 |
then show ?case by (auto simp: add_strict_mono) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
590 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
591 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
592 |
lemma setsum_strict_mono_ex1: |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
593 |
fixes f g :: "'i \<Rightarrow> 'a::ordered_cancel_comm_monoid_add" |
63654 | 594 |
assumes "finite A" |
595 |
and "\<forall>x\<in>A. f x \<le> g x" |
|
596 |
and "\<exists>a\<in>A. f a < g a" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
597 |
shows "setsum f A < setsum g A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
598 |
proof- |
63654 | 599 |
from assms(3) obtain a where a: "a \<in> A" "f a < g a" by blast |
600 |
have "setsum f A = setsum f ((A - {a}) \<union> {a})" |
|
601 |
by(simp add: insert_absorb[OF \<open>a \<in> A\<close>]) |
|
602 |
also have "\<dots> = setsum f (A - {a}) + setsum f {a}" |
|
60758 | 603 |
using \<open>finite A\<close> by(subst setsum.union_disjoint) auto |
63654 | 604 |
also have "setsum f (A - {a}) \<le> setsum g (A - {a})" |
605 |
by (rule setsum_mono) (simp add: assms(2)) |
|
606 |
also from a have "setsum f {a} < setsum g {a}" by simp |
|
607 |
also have "setsum g (A - {a}) + setsum g {a} = setsum g((A - {a}) \<union> {a})" |
|
608 |
using \<open>finite A\<close> by (subst setsum.union_disjoint[symmetric]) auto |
|
609 |
also have "\<dots> = setsum g A" by (simp add: insert_absorb[OF \<open>a \<in> A\<close>]) |
|
610 |
finally show ?thesis |
|
611 |
by (auto simp add: add_right_mono add_strict_left_mono) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
612 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
613 |
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
614 |
lemma setsum_mono_inv: |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
615 |
fixes f g :: "'i \<Rightarrow> 'a :: ordered_cancel_comm_monoid_add" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
616 |
assumes eq: "setsum f I = setsum g I" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
617 |
assumes le: "\<And>i. i \<in> I \<Longrightarrow> f i \<le> g i" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
618 |
assumes i: "i \<in> I" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
619 |
assumes I: "finite I" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
620 |
shows "f i = g i" |
63654 | 621 |
proof (rule ccontr) |
622 |
assume "\<not> ?thesis" |
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
623 |
with le[OF i] have "f i < g i" by simp |
63654 | 624 |
with i have "\<exists>i\<in>I. f i < g i" .. |
625 |
from setsum_strict_mono_ex1[OF I _ this] le have "setsum f I < setsum g I" |
|
626 |
by blast |
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
627 |
with eq show False by simp |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
628 |
qed |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
629 |
|
63938 | 630 |
lemma member_le_setsum: |
631 |
fixes f :: "_ \<Rightarrow> 'b::{semiring_1, ordered_comm_monoid_add}" |
|
632 |
assumes le: "\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x" |
|
633 |
and "i \<in> A" |
|
634 |
and "finite A" |
|
635 |
shows "f i \<le> setsum f A" |
|
636 |
proof - |
|
637 |
have "f i \<le> setsum f (A \<inter> {i})" |
|
638 |
by (simp add: assms) |
|
639 |
also have "... = (\<Sum>x\<in>A. if x \<in> {i} then f x else 0)" |
|
640 |
using assms setsum.inter_restrict by blast |
|
641 |
also have "... \<le> setsum f A" |
|
642 |
apply (rule setsum_mono) |
|
643 |
apply (auto simp: le) |
|
644 |
done |
|
645 |
finally show ?thesis . |
|
646 |
qed |
|
647 |
||
63654 | 648 |
lemma setsum_negf: "(\<Sum>x\<in>A. - f x) = - (\<Sum>x\<in>A. f x)" |
649 |
for f :: "'b \<Rightarrow> 'a::ab_group_add" |
|
63915 | 650 |
by (induct A rule: infinite_finite_induct) auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
651 |
|
63654 | 652 |
lemma setsum_subtractf: "(\<Sum>x\<in>A. f x - g x) = (\<Sum>x\<in>A. f x) - (\<Sum>x\<in>A. g x)" |
653 |
for f g :: "'b \<Rightarrow>'a::ab_group_add" |
|
57418 | 654 |
using setsum.distrib [of f "- g" A] by (simp add: setsum_negf) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
655 |
|
59416
fde2659085e1
generalized sum_diff_distrib to setsum_subtractf_nat
hoelzl
parents:
59010
diff
changeset
|
656 |
lemma setsum_subtractf_nat: |
63654 | 657 |
"(\<And>x. x \<in> A \<Longrightarrow> g x \<le> f x) \<Longrightarrow> (\<Sum>x\<in>A. f x - g x) = (\<Sum>x\<in>A. f x) - (\<Sum>x\<in>A. g x)" |
658 |
for f g :: "'a \<Rightarrow> nat" |
|
659 |
by (induct A rule: infinite_finite_induct) (auto simp: setsum_mono) |
|
59416
fde2659085e1
generalized sum_diff_distrib to setsum_subtractf_nat
hoelzl
parents:
59010
diff
changeset
|
660 |
|
63654 | 661 |
context ordered_comm_monoid_add |
662 |
begin |
|
663 |
||
63915 | 664 |
lemma setsum_nonneg: "\<forall>x\<in>A. 0 \<le> f x \<Longrightarrow> 0 \<le> setsum f A" |
665 |
proof (induct A rule: infinite_finite_induct) |
|
666 |
case infinite |
|
667 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
668 |
next |
63915 | 669 |
case empty |
670 |
then show ?case by simp |
|
671 |
next |
|
672 |
case (insert x F) |
|
673 |
then have "0 + 0 \<le> f x + setsum f F" by (blast intro: add_mono) |
|
674 |
with insert show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
675 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
676 |
|
63915 | 677 |
lemma setsum_nonpos: "\<forall>x\<in>A. f x \<le> 0 \<Longrightarrow> setsum f A \<le> 0" |
678 |
proof (induct A rule: infinite_finite_induct) |
|
679 |
case infinite |
|
680 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
681 |
next |
63915 | 682 |
case empty |
683 |
then show ?case by simp |
|
684 |
next |
|
685 |
case (insert x F) |
|
686 |
then have "f x + setsum f F \<le> 0 + 0" by (blast intro: add_mono) |
|
687 |
with insert show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
688 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
689 |
|
63654 | 690 |
lemma setsum_nonneg_eq_0_iff: |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
691 |
"finite A \<Longrightarrow> \<forall>x\<in>A. 0 \<le> f x \<Longrightarrow> setsum f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)" |
63654 | 692 |
by (induct set: finite) (simp_all add: add_nonneg_eq_0_iff setsum_nonneg) |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
693 |
|
63654 | 694 |
lemma setsum_nonneg_0: |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
695 |
"finite s \<Longrightarrow> (\<And>i. i \<in> s \<Longrightarrow> f i \<ge> 0) \<Longrightarrow> (\<Sum> i \<in> s. f i) = 0 \<Longrightarrow> i \<in> s \<Longrightarrow> f i = 0" |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
696 |
by (simp add: setsum_nonneg_eq_0_iff) |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
697 |
|
63654 | 698 |
lemma setsum_nonneg_leq_bound: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
699 |
assumes "finite s" "\<And>i. i \<in> s \<Longrightarrow> f i \<ge> 0" "(\<Sum>i \<in> s. f i) = B" "i \<in> s" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
700 |
shows "f i \<le> B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
701 |
proof - |
63654 | 702 |
from assms have "f i \<le> f i + (\<Sum>i \<in> s - {i}. f i)" |
703 |
by (intro add_increasing2 setsum_nonneg) auto |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
704 |
also have "\<dots> = B" |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
705 |
using setsum.remove[of s i f] assms by simp |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
706 |
finally show ?thesis by auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
707 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
708 |
|
63654 | 709 |
lemma setsum_mono2: |
710 |
assumes fin: "finite B" |
|
711 |
and sub: "A \<subseteq> B" |
|
712 |
and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
713 |
shows "setsum f A \<le> setsum f B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
714 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
715 |
have "setsum f A \<le> setsum f A + setsum f (B-A)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
716 |
by(simp add: add_increasing2[OF setsum_nonneg] nn Ball_def) |
63654 | 717 |
also from fin finite_subset[OF sub fin] have "\<dots> = setsum f (A \<union> (B-A))" |
718 |
by (simp add: setsum.union_disjoint del: Un_Diff_cancel) |
|
719 |
also from sub have "A \<union> (B-A) = B" by blast |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
720 |
finally show ?thesis . |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
721 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
722 |
|
63654 | 723 |
lemma setsum_le_included: |
57418 | 724 |
assumes "finite s" "finite t" |
725 |
and "\<forall>y\<in>t. 0 \<le> g y" "(\<forall>x\<in>s. \<exists>y\<in>t. i y = x \<and> f x \<le> g y)" |
|
726 |
shows "setsum f s \<le> setsum g t" |
|
727 |
proof - |
|
728 |
have "setsum f s \<le> setsum (\<lambda>y. setsum g {x. x\<in>t \<and> i x = y}) s" |
|
729 |
proof (rule setsum_mono) |
|
63654 | 730 |
fix y |
731 |
assume "y \<in> s" |
|
57418 | 732 |
with assms obtain z where z: "z \<in> t" "y = i z" "f y \<le> g z" by auto |
733 |
with assms show "f y \<le> setsum g {x \<in> t. i x = y}" (is "?A y \<le> ?B y") |
|
734 |
using order_trans[of "?A (i z)" "setsum g {z}" "?B (i z)", intro] |
|
735 |
by (auto intro!: setsum_mono2) |
|
736 |
qed |
|
63654 | 737 |
also have "\<dots> \<le> setsum (\<lambda>y. setsum g {x. x\<in>t \<and> i x = y}) (i ` t)" |
57418 | 738 |
using assms(2-4) by (auto intro!: setsum_mono2 setsum_nonneg) |
63654 | 739 |
also have "\<dots> \<le> setsum g t" |
57418 | 740 |
using assms by (auto simp: setsum_image_gen[symmetric]) |
741 |
finally show ?thesis . |
|
742 |
qed |
|
743 |
||
63654 | 744 |
lemma setsum_mono3: "finite B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> \<forall>x\<in>B - A. 0 \<le> f x \<Longrightarrow> setsum f A \<le> setsum f B" |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
745 |
by (rule setsum_mono2) auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
746 |
|
63654 | 747 |
end |
748 |
||
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
749 |
lemma (in canonically_ordered_monoid_add) setsum_eq_0_iff [simp]: |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
750 |
"finite F \<Longrightarrow> (setsum f F = 0) = (\<forall>a\<in>F. f a = 0)" |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
751 |
by (intro ballI setsum_nonneg_eq_0_iff zero_le) |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
752 |
|
63918
6bf55e6e0b75
left_distrib ~> distrib_right, right_distrib ~> distrib_left
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63915
diff
changeset
|
753 |
lemma setsum_distrib_left: "r * setsum f A = setsum (\<lambda>n. r * f n) A" |
63915 | 754 |
for f :: "'a \<Rightarrow> 'b::semiring_0" |
755 |
proof (induct A rule: infinite_finite_induct) |
|
756 |
case infinite |
|
757 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
758 |
next |
63915 | 759 |
case empty |
760 |
then show ?case by simp |
|
761 |
next |
|
762 |
case insert |
|
763 |
then show ?case by (simp add: distrib_left) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
764 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
765 |
|
63918
6bf55e6e0b75
left_distrib ~> distrib_right, right_distrib ~> distrib_left
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63915
diff
changeset
|
766 |
lemma setsum_distrib_right: "setsum f A * r = (\<Sum>n\<in>A. f n * r)" |
63654 | 767 |
for r :: "'a::semiring_0" |
63915 | 768 |
proof (induct A rule: infinite_finite_induct) |
769 |
case infinite |
|
770 |
then show ?case by simp |
|
63654 | 771 |
next |
63915 | 772 |
case empty |
773 |
then show ?case by simp |
|
774 |
next |
|
775 |
case insert |
|
776 |
then show ?case by (simp add: distrib_right) |
|
63654 | 777 |
qed |
778 |
||
779 |
lemma setsum_divide_distrib: "setsum f A / r = (\<Sum>n\<in>A. f n / r)" |
|
780 |
for r :: "'a::field" |
|
63915 | 781 |
proof (induct A rule: infinite_finite_induct) |
782 |
case infinite |
|
783 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
784 |
next |
63915 | 785 |
case empty |
786 |
then show ?case by simp |
|
787 |
next |
|
788 |
case insert |
|
789 |
then show ?case by (simp add: add_divide_distrib) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
790 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
791 |
|
63654 | 792 |
lemma setsum_abs[iff]: "\<bar>setsum f A\<bar> \<le> setsum (\<lambda>i. \<bar>f i\<bar>) A" |
793 |
for f :: "'a \<Rightarrow> 'b::ordered_ab_group_add_abs" |
|
63915 | 794 |
proof (induct A rule: infinite_finite_induct) |
795 |
case infinite |
|
796 |
then show ?case by simp |
|
63654 | 797 |
next |
63915 | 798 |
case empty |
799 |
then show ?case by simp |
|
800 |
next |
|
801 |
case insert |
|
802 |
then show ?case by (auto intro: abs_triangle_ineq order_trans) |
|
63654 | 803 |
qed |
804 |
||
805 |
lemma setsum_abs_ge_zero[iff]: "0 \<le> setsum (\<lambda>i. \<bar>f i\<bar>) A" |
|
806 |
for f :: "'a \<Rightarrow> 'b::ordered_ab_group_add_abs" |
|
807 |
by (simp add: setsum_nonneg) |
|
808 |
||
809 |
lemma abs_setsum_abs[simp]: "\<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar> = (\<Sum>a\<in>A. \<bar>f a\<bar>)" |
|
810 |
for f :: "'a \<Rightarrow> 'b::ordered_ab_group_add_abs" |
|
63915 | 811 |
proof (induct A rule: infinite_finite_induct) |
812 |
case infinite |
|
813 |
then show ?case by simp |
|
814 |
next |
|
815 |
case empty |
|
816 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
817 |
next |
63915 | 818 |
case (insert a A) |
819 |
then have "\<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 |
|
820 |
also from insert have "\<dots> = \<bar>\<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>\<bar>" by simp |
|
821 |
also have "\<dots> = \<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>" by (simp del: abs_of_nonneg) |
|
822 |
also from insert have "\<dots> = (\<Sum>a\<in>insert a A. \<bar>f a\<bar>)" by simp |
|
823 |
finally show ?case . |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
824 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
825 |
|
63654 | 826 |
lemma setsum_diff1_ring: |
827 |
fixes f :: "'b \<Rightarrow> 'a::ring" |
|
828 |
assumes "finite A" "a \<in> A" |
|
829 |
shows "setsum f (A - {a}) = setsum f A - (f a)" |
|
57418 | 830 |
unfolding setsum.remove [OF assms] by auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
831 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
832 |
lemma setsum_product: |
63654 | 833 |
fixes f :: "'a \<Rightarrow> 'b::semiring_0" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
834 |
shows "setsum f A * setsum g B = (\<Sum>i\<in>A. \<Sum>j\<in>B. f i * g j)" |
63918
6bf55e6e0b75
left_distrib ~> distrib_right, right_distrib ~> distrib_left
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63915
diff
changeset
|
835 |
by (simp add: setsum_distrib_left setsum_distrib_right) (rule setsum.commute) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
836 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
837 |
lemma setsum_mult_setsum_if_inj: |
63654 | 838 |
fixes f :: "'a \<Rightarrow> 'b::semiring_0" |
839 |
shows "inj_on (\<lambda>(a, b). f a * g b) (A \<times> B) \<Longrightarrow> |
|
840 |
setsum f A * setsum g B = setsum id {f a * g b |a b. a \<in> A \<and> b \<in> B}" |
|
841 |
by(auto simp: setsum_product setsum.cartesian_product intro!: setsum.reindex_cong[symmetric]) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
842 |
|
63915 | 843 |
lemma setsum_SucD: "setsum f A = Suc n \<Longrightarrow> \<exists>a\<in>A. 0 < f a" |
844 |
by (induct A rule: infinite_finite_induct) auto |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
845 |
|
63654 | 846 |
lemma setsum_eq_Suc0_iff: |
63915 | 847 |
"finite A \<Longrightarrow> setsum f A = Suc 0 \<longleftrightarrow> (\<exists>a\<in>A. f a = Suc 0 \<and> (\<forall>b\<in>A. a \<noteq> b \<longrightarrow> f b = 0))" |
848 |
by (induct A rule: finite_induct) (auto simp add: add_is_1) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
849 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
850 |
lemmas setsum_eq_1_iff = setsum_eq_Suc0_iff[simplified One_nat_def[symmetric]] |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
851 |
|
63654 | 852 |
lemma setsum_Un_nat: |
853 |
"finite A \<Longrightarrow> finite B \<Longrightarrow> setsum f (A \<union> B) = setsum f A + setsum f B - setsum f (A \<inter> B)" |
|
854 |
for f :: "'a \<Rightarrow> nat" |
|
61799 | 855 |
\<comment> \<open>For the natural numbers, we have subtraction.\<close> |
63654 | 856 |
by (subst setsum.union_inter [symmetric]) (auto simp: algebra_simps) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
857 |
|
63654 | 858 |
lemma setsum_diff1_nat: "setsum f (A - {a}) = (if a \<in> A then setsum f A - f a else setsum f A)" |
859 |
for f :: "'a \<Rightarrow> nat" |
|
63915 | 860 |
proof (induct A rule: infinite_finite_induct) |
861 |
case infinite |
|
862 |
then show ?case by simp |
|
863 |
next |
|
864 |
case empty |
|
865 |
then show ?case by simp |
|
866 |
next |
|
867 |
case insert |
|
868 |
then show ?case |
|
869 |
apply (auto simp: insert_Diff_if) |
|
63654 | 870 |
apply (drule mk_disjoint_insert) |
871 |
apply auto |
|
872 |
done |
|
873 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
874 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
875 |
lemma setsum_diff_nat: |
63654 | 876 |
fixes f :: "'a \<Rightarrow> nat" |
877 |
assumes "finite B" and "B \<subseteq> A" |
|
878 |
shows "setsum f (A - B) = setsum f A - setsum f B" |
|
879 |
using assms |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
880 |
proof induct |
63654 | 881 |
case empty |
882 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
883 |
next |
63654 | 884 |
case (insert x F) |
885 |
note IH = \<open>F \<subseteq> A \<Longrightarrow> setsum f (A - F) = setsum f A - setsum f F\<close> |
|
886 |
from \<open>x \<notin> F\<close> \<open>insert x F \<subseteq> A\<close> have "x \<in> A - F" by simp |
|
887 |
then have A: "setsum f ((A - F) - {x}) = setsum f (A - F) - f x" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
888 |
by (simp add: setsum_diff1_nat) |
63654 | 889 |
from \<open>insert x F \<subseteq> A\<close> have "F \<subseteq> A" by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
890 |
with IH have "setsum f (A - F) = setsum f A - setsum f F" by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
891 |
with A have B: "setsum f ((A - F) - {x}) = setsum f A - setsum f F - f x" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
892 |
by simp |
63654 | 893 |
from \<open>x \<notin> F\<close> have "A - insert x F = (A - F) - {x}" by auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
894 |
with B have C: "setsum f (A - insert x F) = setsum f A - setsum f F - f x" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
895 |
by simp |
63654 | 896 |
from \<open>finite F\<close> \<open>x \<notin> F\<close> have "setsum f (insert x F) = setsum f F + f x" |
897 |
by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
898 |
with C have "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
899 |
by simp |
63654 | 900 |
then show ?case by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
901 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
902 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
903 |
lemma setsum_comp_morphism: |
63915 | 904 |
"h 0 = 0 \<Longrightarrow> (\<And>x y. h (x + y) = h x + h y) \<Longrightarrow> setsum (h \<circ> g) A = h (setsum g A)" |
905 |
by (induct A rule: infinite_finite_induct) simp_all |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
906 |
|
63654 | 907 |
lemma (in comm_semiring_1) dvd_setsum: "(\<And>a. a \<in> A \<Longrightarrow> d dvd f a) \<Longrightarrow> d dvd setsum f A" |
59010 | 908 |
by (induct A rule: infinite_finite_induct) simp_all |
909 |
||
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
910 |
lemma (in ordered_comm_monoid_add) setsum_pos: |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
911 |
"finite I \<Longrightarrow> I \<noteq> {} \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> 0 < f i) \<Longrightarrow> 0 < setsum f I" |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
912 |
by (induct I rule: finite_ne_induct) (auto intro: add_pos_pos) |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
913 |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
914 |
lemma (in ordered_comm_monoid_add) setsum_pos2: |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
915 |
assumes I: "finite I" "i \<in> I" "0 < f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
916 |
shows "0 < setsum f I" |
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
917 |
proof - |
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
918 |
have "0 < f i + setsum f (I - {i})" |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
919 |
using assms by (intro add_pos_nonneg setsum_nonneg) auto |
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
920 |
also have "\<dots> = setsum f I" |
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
921 |
using assms by (simp add: setsum.remove) |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
922 |
finally show ?thesis . |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
923 |
qed |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
924 |
|
61524
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
eberlm
parents:
61378
diff
changeset
|
925 |
lemma setsum_cong_Suc: |
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
eberlm
parents:
61378
diff
changeset
|
926 |
assumes "0 \<notin> A" "\<And>x. Suc x \<in> A \<Longrightarrow> f (Suc x) = g (Suc x)" |
63654 | 927 |
shows "setsum f A = setsum g A" |
61524
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
eberlm
parents:
61378
diff
changeset
|
928 |
proof (rule setsum.cong) |
63654 | 929 |
fix x |
930 |
assume "x \<in> A" |
|
931 |
with assms(1) show "f x = g x" |
|
932 |
by (cases x) (auto intro!: assms(2)) |
|
61524
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
eberlm
parents:
61378
diff
changeset
|
933 |
qed simp_all |
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
eberlm
parents:
61378
diff
changeset
|
934 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
935 |
|
60758 | 936 |
subsubsection \<open>Cardinality as special case of @{const setsum}\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
937 |
|
63654 | 938 |
lemma card_eq_setsum: "card A = setsum (\<lambda>x. 1) A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
939 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
940 |
have "plus \<circ> (\<lambda>_. Suc 0) = (\<lambda>_. Suc)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
941 |
by (simp add: fun_eq_iff) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
942 |
then have "Finite_Set.fold (plus \<circ> (\<lambda>_. Suc 0)) = Finite_Set.fold (\<lambda>_. Suc)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
943 |
by (rule arg_cong) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
944 |
then have "Finite_Set.fold (plus \<circ> (\<lambda>_. Suc 0)) 0 A = Finite_Set.fold (\<lambda>_. Suc) 0 A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
945 |
by (blast intro: fun_cong) |
63654 | 946 |
then show ?thesis |
947 |
by (simp add: card.eq_fold setsum.eq_fold) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
948 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
949 |
|
63654 | 950 |
lemma setsum_constant [simp]: "(\<Sum>x \<in> A. y) = of_nat (card A) * y" |
63915 | 951 |
by (induct A rule: infinite_finite_induct) (auto simp: algebra_simps) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
952 |
|
59615
fdfdf89a83a6
A few new lemmas and a bit of tidying up
paulson <lp15@cam.ac.uk>
parents:
59416
diff
changeset
|
953 |
lemma setsum_Suc: "setsum (\<lambda>x. Suc(f x)) A = setsum f A + card A" |
63654 | 954 |
using setsum.distrib[of f "\<lambda>_. 1" A] by simp |
58349 | 955 |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
956 |
lemma setsum_bounded_above: |
63654 | 957 |
fixes K :: "'a::{semiring_1,ordered_comm_monoid_add}" |
958 |
assumes le: "\<And>i. i\<in>A \<Longrightarrow> f i \<le> K" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
959 |
shows "setsum f A \<le> of_nat (card A) * K" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
960 |
proof (cases "finite A") |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
961 |
case True |
63654 | 962 |
then show ?thesis |
963 |
using le setsum_mono[where K=A and g = "\<lambda>x. K"] by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
964 |
next |
63654 | 965 |
case False |
966 |
then show ?thesis by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
967 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
968 |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
969 |
lemma setsum_bounded_above_strict: |
63654 | 970 |
fixes K :: "'a::{ordered_cancel_comm_monoid_add,semiring_1}" |
971 |
assumes "\<And>i. i\<in>A \<Longrightarrow> f i < K" "card A > 0" |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
972 |
shows "setsum f A < of_nat (card A) * K" |
63654 | 973 |
using assms setsum_strict_mono[where A=A and g = "\<lambda>x. K"] |
974 |
by (simp add: card_gt_0_iff) |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
975 |
|
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
976 |
lemma setsum_bounded_below: |
63654 | 977 |
fixes K :: "'a::{semiring_1,ordered_comm_monoid_add}" |
978 |
assumes le: "\<And>i. i\<in>A \<Longrightarrow> K \<le> f i" |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
979 |
shows "of_nat (card A) * K \<le> setsum f A" |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
980 |
proof (cases "finite A") |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
981 |
case True |
63654 | 982 |
then show ?thesis |
63915 | 983 |
using le setsum_mono[where K=A and f = "\<lambda>x. K"] by simp |
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
984 |
next |
63654 | 985 |
case False |
986 |
then show ?thesis by simp |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
987 |
qed |
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
988 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
989 |
lemma card_UN_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
990 |
assumes "finite I" and "\<forall>i\<in>I. finite (A i)" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
991 |
and "\<forall>i\<in>I. \<forall>j\<in>I. i \<noteq> j \<longrightarrow> A i \<inter> A j = {}" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
992 |
shows "card (UNION I A) = (\<Sum>i\<in>I. card(A i))" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
993 |
proof - |
63654 | 994 |
have "(\<Sum>i\<in>I. card (A i)) = (\<Sum>i\<in>I. \<Sum>x\<in>A i. 1)" |
995 |
by simp |
|
996 |
with assms show ?thesis |
|
997 |
by (simp add: card_eq_setsum setsum.UNION_disjoint del: setsum_constant) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
998 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
999 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1000 |
lemma card_Union_disjoint: |
63654 | 1001 |
"finite C \<Longrightarrow> \<forall>A\<in>C. finite A \<Longrightarrow> \<forall>A\<in>C. \<forall>B\<in>C. A \<noteq> B \<longrightarrow> A \<inter> B = {} \<Longrightarrow> |
1002 |
card (\<Union>C) = setsum card C" |
|
1003 |
by (frule card_UN_disjoint [of C id]) simp_all |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1004 |
|
57418 | 1005 |
lemma setsum_multicount_gen: |
1006 |
assumes "finite s" "finite t" "\<forall>j\<in>t. (card {i\<in>s. R i j} = k j)" |
|
63654 | 1007 |
shows "setsum (\<lambda>i. (card {j\<in>t. R i j})) s = setsum k t" |
1008 |
(is "?l = ?r") |
|
57418 | 1009 |
proof- |
63654 | 1010 |
have "?l = setsum (\<lambda>i. setsum (\<lambda>x.1) {j\<in>t. R i j}) s" |
1011 |
by auto |
|
1012 |
also have "\<dots> = ?r" |
|
1013 |
unfolding setsum.commute_restrict [OF assms(1-2)] |
|
57418 | 1014 |
using assms(3) by auto |
1015 |
finally show ?thesis . |
|
1016 |
qed |
|
1017 |
||
1018 |
lemma setsum_multicount: |
|
1019 |
assumes "finite S" "finite T" "\<forall>j\<in>T. (card {i\<in>S. R i j} = k)" |
|
1020 |
shows "setsum (\<lambda>i. card {j\<in>T. R i j}) S = k * card T" (is "?l = ?r") |
|
1021 |
proof- |
|
63654 | 1022 |
have "?l = setsum (\<lambda>i. k) T" |
1023 |
by (rule setsum_multicount_gen) (auto simp: assms) |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
1024 |
also have "\<dots> = ?r" by (simp add: mult.commute) |
57418 | 1025 |
finally show ?thesis by auto |
1026 |
qed |
|
1027 |
||
63654 | 1028 |
|
60758 | 1029 |
subsubsection \<open>Cardinality of products\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1030 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1031 |
lemma card_SigmaI [simp]: |
63654 | 1032 |
"finite A \<Longrightarrow> \<forall>a\<in>A. finite (B a) \<Longrightarrow> card (SIGMA x: A. B x) = (\<Sum>a\<in>A. card (B a))" |
1033 |
by (simp add: card_eq_setsum setsum.Sigma del: setsum_constant) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1034 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1035 |
(* |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1036 |
lemma SigmaI_insert: "y \<notin> A ==> |
61943 | 1037 |
(SIGMA x:(insert y A). B x) = (({y} \<times> (B y)) \<union> (SIGMA x: A. B x))" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1038 |
by auto |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1039 |
*) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1040 |
|
63654 | 1041 |
lemma card_cartesian_product: "card (A \<times> B) = card A * card B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1042 |
by (cases "finite A \<and> finite B") |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1043 |
(auto simp add: card_eq_0_iff dest: finite_cartesian_productD1 finite_cartesian_productD2) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1044 |
|
63654 | 1045 |
lemma card_cartesian_product_singleton: "card ({x} \<times> A) = card A" |
1046 |
by (simp add: card_cartesian_product) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1047 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1048 |
|
60758 | 1049 |
subsection \<open>Generalized product over a set\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1050 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1051 |
context comm_monoid_mult |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1052 |
begin |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1053 |
|
61605 | 1054 |
sublocale setprod: comm_monoid_set times 1 |
63654 | 1055 |
defines setprod = setprod.F .. |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1056 |
|
63654 | 1057 |
abbreviation Setprod ("\<Prod>_" [1000] 999) |
1058 |
where "\<Prod>A \<equiv> setprod (\<lambda>x. x) A" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1059 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1060 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1061 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1062 |
syntax (ASCII) |
60494
e726f88232d3
correccted the pretty-printing specs for setsum and setprod
paulson <lp15@cam.ac.uk>
parents:
60429
diff
changeset
|
1063 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(4PROD _:_./ _)" [0, 51, 10] 10) |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1064 |
syntax |
60494
e726f88232d3
correccted the pretty-printing specs for setsum and setprod
paulson <lp15@cam.ac.uk>
parents:
60429
diff
changeset
|
1065 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(2\<Prod>_\<in>_./ _)" [0, 51, 10] 10) |
61799 | 1066 |
translations \<comment> \<open>Beware of argument permutation!\<close> |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
1067 |
"\<Prod>i\<in>A. b" == "CONST setprod (\<lambda>i. b) A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1068 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1069 |
text \<open>Instead of @{term"\<Prod>x\<in>{x. P}. e"} we introduce the shorter \<open>\<Prod>x|P. e\<close>.\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1070 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1071 |
syntax (ASCII) |
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1072 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(4PROD _ |/ _./ _)" [0, 0, 10] 10) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1073 |
syntax |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1074 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(2\<Prod>_ | (_)./ _)" [0, 0, 10] 10) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1075 |
translations |
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
1076 |
"\<Prod>x|P. t" => "CONST setprod (\<lambda>x. t) {x. P}" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1077 |
|
59010 | 1078 |
context comm_monoid_mult |
1079 |
begin |
|
1080 |
||
63654 | 1081 |
lemma setprod_dvd_setprod: "(\<And>a. a \<in> A \<Longrightarrow> f a dvd g a) \<Longrightarrow> setprod f A dvd setprod g A" |
59010 | 1082 |
proof (induct A rule: infinite_finite_induct) |
63654 | 1083 |
case infinite |
1084 |
then show ?case by (auto intro: dvdI) |
|
1085 |
next |
|
1086 |
case empty |
|
1087 |
then show ?case by (auto intro: dvdI) |
|
59010 | 1088 |
next |
63654 | 1089 |
case (insert a A) |
1090 |
then have "f a dvd g a" and "setprod f A dvd setprod g A" |
|
1091 |
by simp_all |
|
1092 |
then obtain r s where "g a = f a * r" and "setprod g A = setprod f A * s" |
|
1093 |
by (auto elim!: dvdE) |
|
1094 |
then have "g a * setprod g A = f a * setprod f A * (r * s)" |
|
1095 |
by (simp add: ac_simps) |
|
1096 |
with insert.hyps show ?case |
|
1097 |
by (auto intro: dvdI) |
|
59010 | 1098 |
qed |
1099 |
||
63654 | 1100 |
lemma setprod_dvd_setprod_subset: "finite B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> setprod f A dvd setprod f B" |
59010 | 1101 |
by (auto simp add: setprod.subset_diff ac_simps intro: dvdI) |
1102 |
||
1103 |
end |
|
1104 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1105 |
|
60758 | 1106 |
subsubsection \<open>Properties in more restricted classes of structures\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1107 |
|
59010 | 1108 |
context comm_semiring_1 |
1109 |
begin |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1110 |
|
59010 | 1111 |
lemma dvd_setprod_eqI [intro]: |
1112 |
assumes "finite A" and "a \<in> A" and "b = f a" |
|
1113 |
shows "b dvd setprod f A" |
|
1114 |
proof - |
|
60758 | 1115 |
from \<open>finite A\<close> have "setprod f (insert a (A - {a})) = f a * setprod f (A - {a})" |
59010 | 1116 |
by (intro setprod.insert) auto |
63654 | 1117 |
also from \<open>a \<in> A\<close> have "insert a (A - {a}) = A" |
1118 |
by blast |
|
59010 | 1119 |
finally have "setprod f A = f a * setprod f (A - {a})" . |
63654 | 1120 |
with \<open>b = f a\<close> show ?thesis |
1121 |
by simp |
|
59010 | 1122 |
qed |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1123 |
|
63654 | 1124 |
lemma dvd_setprodI [intro]: "finite A \<Longrightarrow> a \<in> A \<Longrightarrow> f a dvd setprod f A" |
1125 |
by auto |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1126 |
|
59010 | 1127 |
lemma setprod_zero: |
1128 |
assumes "finite A" and "\<exists>a\<in>A. f a = 0" |
|
1129 |
shows "setprod f A = 0" |
|
63654 | 1130 |
using assms |
1131 |
proof (induct A) |
|
1132 |
case empty |
|
1133 |
then show ?case by simp |
|
59010 | 1134 |
next |
1135 |
case (insert a A) |
|
1136 |
then have "f a = 0 \<or> (\<exists>a\<in>A. f a = 0)" by simp |
|
1137 |
then have "f a * setprod f A = 0" by rule (simp_all add: insert) |
|
1138 |
with insert show ?case by simp |
|
1139 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1140 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1141 |
lemma setprod_dvd_setprod_subset2: |
59010 | 1142 |
assumes "finite B" and "A \<subseteq> B" and "\<And>a. a \<in> A \<Longrightarrow> f a dvd g a" |
1143 |
shows "setprod f A dvd setprod g B" |
|
1144 |
proof - |
|
1145 |
from assms have "setprod f A dvd setprod g A" |
|
1146 |
by (auto intro: setprod_dvd_setprod) |
|
1147 |
moreover from assms have "setprod g A dvd setprod g B" |
|
1148 |
by (auto intro: setprod_dvd_setprod_subset) |
|
1149 |
ultimately show ?thesis by (rule dvd_trans) |
|
1150 |
qed |
|
1151 |
||
1152 |
end |
|
1153 |
||
63924 | 1154 |
lemma (in semidom) setprod_zero_iff [simp]: |
1155 |
fixes f :: "'b \<Rightarrow> 'a" |
|
59010 | 1156 |
assumes "finite A" |
63654 | 1157 |
shows "setprod f A = 0 \<longleftrightarrow> (\<exists>a\<in>A. f a = 0)" |
59010 | 1158 |
using assms by (induct A) (auto simp: no_zero_divisors) |
1159 |
||
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1160 |
lemma (in semidom_divide) setprod_diff1: |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1161 |
assumes "finite A" and "f a \<noteq> 0" |
60429
d3d1e185cd63
uniform _ div _ as infix syntax for ring division
haftmann
parents:
60353
diff
changeset
|
1162 |
shows "setprod f (A - {a}) = (if a \<in> A then setprod f A div f a else setprod f A)" |
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1163 |
proof (cases "a \<notin> A") |
63654 | 1164 |
case True |
1165 |
then show ?thesis by simp |
|
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1166 |
next |
63654 | 1167 |
case False |
1168 |
with assms show ?thesis |
|
1169 |
proof induct |
|
1170 |
case empty |
|
1171 |
then show ?case by simp |
|
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1172 |
next |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1173 |
case (insert b B) |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1174 |
then show ?case |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1175 |
proof (cases "a = b") |
63654 | 1176 |
case True |
1177 |
with insert show ?thesis by simp |
|
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1178 |
next |
63654 | 1179 |
case False |
1180 |
with insert have "a \<in> B" by simp |
|
63040 | 1181 |
define C where "C = B - {a}" |
63654 | 1182 |
with \<open>finite B\<close> \<open>a \<in> B\<close> have "B = insert a C" "finite C" "a \<notin> C" |
1183 |
by auto |
|
1184 |
with insert show ?thesis |
|
1185 |
by (auto simp add: insert_commute ac_simps) |
|
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1186 |
qed |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1187 |
qed |
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
59867
diff
changeset
|
1188 |
qed |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1189 |
|
63654 | 1190 |
lemma setsum_zero_power [simp]: "(\<Sum>i\<in>A. c i * 0^i) = (if finite A \<and> 0 \<in> A then c 0 else 0)" |
1191 |
for c :: "nat \<Rightarrow> 'a::division_ring" |
|
1192 |
by (induct A rule: infinite_finite_induct) auto |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1193 |
|
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1194 |
lemma setsum_zero_power' [simp]: |
63654 | 1195 |
"(\<Sum>i\<in>A. c i * 0^i / d i) = (if finite A \<and> 0 \<in> A then c 0 / d 0 else 0)" |
1196 |
for c :: "nat \<Rightarrow> 'a::field" |
|
1197 |
using setsum_zero_power [of "\<lambda>i. c i / d i" A] by auto |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1198 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
1199 |
lemma (in field) setprod_inversef: |
59010 | 1200 |
"finite A \<Longrightarrow> setprod (inverse \<circ> f) A = inverse (setprod f A)" |
1201 |
by (induct A rule: finite_induct) simp_all |
|
1202 |
||
63654 | 1203 |
lemma (in field) setprod_dividef: "finite A \<Longrightarrow> (\<Prod>x\<in>A. f x / g x) = setprod f A / setprod g A" |
59010 | 1204 |
using setprod_inversef [of A g] by (simp add: divide_inverse setprod.distrib) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1205 |
|
59010 | 1206 |
lemma setprod_Un: |
1207 |
fixes f :: "'b \<Rightarrow> 'a :: field" |
|
1208 |
assumes "finite A" and "finite B" |
|
63654 | 1209 |
and "\<forall>x\<in>A \<inter> B. f x \<noteq> 0" |
59010 | 1210 |
shows "setprod f (A \<union> B) = setprod f A * setprod f B / setprod f (A \<inter> B)" |
1211 |
proof - |
|
1212 |
from assms have "setprod f A * setprod f B = setprod f (A \<union> B) * setprod f (A \<inter> B)" |
|
1213 |
by (simp add: setprod.union_inter [symmetric, of A B]) |
|
63654 | 1214 |
with assms show ?thesis |
1215 |
by simp |
|
59010 | 1216 |
qed |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1217 |
|
63654 | 1218 |
lemma (in linordered_semidom) setprod_nonneg: "(\<forall>a\<in>A. 0 \<le> f a) \<Longrightarrow> 0 \<le> setprod f A" |
59010 | 1219 |
by (induct A rule: infinite_finite_induct) simp_all |
1220 |
||
63654 | 1221 |
lemma (in linordered_semidom) setprod_pos: "(\<forall>a\<in>A. 0 < f a) \<Longrightarrow> 0 < setprod f A" |
59010 | 1222 |
by (induct A rule: infinite_finite_induct) simp_all |
1223 |
||
1224 |
lemma (in linordered_semidom) setprod_mono: |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
1225 |
"\<forall>i\<in>A. 0 \<le> f i \<and> f i \<le> g i \<Longrightarrow> setprod f A \<le> setprod g A" |
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61955
diff
changeset
|
1226 |
by (induct A rule: infinite_finite_induct) (auto intro!: setprod_nonneg mult_mono) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1227 |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
1228 |
lemma (in linordered_semidom) setprod_mono_strict: |
63654 | 1229 |
assumes "finite A" "\<forall>i\<in>A. 0 \<le> f i \<and> f i < g i" "A \<noteq> {}" |
1230 |
shows "setprod f A < setprod g A" |
|
1231 |
using assms |
|
1232 |
proof (induct A rule: finite_induct) |
|
1233 |
case empty |
|
1234 |
then show ?case by simp |
|
1235 |
next |
|
1236 |
case insert |
|
1237 |
then show ?case by (force intro: mult_strict_mono' setprod_nonneg) |
|
1238 |
qed |
|
60974
6a6f15d8fbc4
New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents:
60758
diff
changeset
|
1239 |
|
63654 | 1240 |
lemma (in linordered_field) abs_setprod: "\<bar>setprod f A\<bar> = (\<Prod>x\<in>A. \<bar>f x\<bar>)" |
59010 | 1241 |
by (induct A rule: infinite_finite_induct) (simp_all add: abs_mult) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1242 |
|
63654 | 1243 |
lemma setprod_eq_1_iff [simp]: "finite A \<Longrightarrow> setprod f A = 1 \<longleftrightarrow> (\<forall>a\<in>A. f a = 1)" |
1244 |
for f :: "'a \<Rightarrow> nat" |
|
59010 | 1245 |
by (induct A rule: finite_induct) simp_all |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1246 |
|
63654 | 1247 |
lemma setprod_pos_nat_iff [simp]: "finite A \<Longrightarrow> setprod f A > 0 \<longleftrightarrow> (\<forall>a\<in>A. f a > 0)" |
1248 |
for f :: "'a \<Rightarrow> nat" |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1249 |
using setprod_zero_iff by (simp del: neq0_conv add: zero_less_iff_neq_zero) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1250 |
|
63654 | 1251 |
lemma setprod_constant: "(\<Prod>x\<in> A. y) = y ^ card A" |
1252 |
for y :: "'a::comm_monoid_mult" |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1253 |
by (induct A rule: infinite_finite_induct) simp_all |
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1254 |
|
63654 | 1255 |
lemma setprod_power_distrib: "setprod f A ^ n = setprod (\<lambda>x. (f x) ^ n) A" |
1256 |
for f :: "'a \<Rightarrow> 'b::comm_semiring_1" |
|
1257 |
by (induct A rule: infinite_finite_induct) (auto simp add: power_mult_distrib) |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1258 |
|
63654 | 1259 |
lemma power_setsum: "c ^ (\<Sum>a\<in>A. f a) = (\<Prod>a\<in>A. c ^ f a)" |
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1260 |
by (induct A rule: infinite_finite_induct) (simp_all add: power_add) |
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1261 |
|
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1262 |
lemma setprod_gen_delta: |
63654 | 1263 |
fixes b :: "'b \<Rightarrow> 'a::comm_monoid_mult" |
1264 |
assumes fin: "finite S" |
|
1265 |
shows "setprod (\<lambda>k. if k = a then b k else c) S = |
|
1266 |
(if a \<in> S then b a * c ^ (card S - 1) else c ^ card S)" |
|
1267 |
proof - |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1268 |
let ?f = "(\<lambda>k. if k=a then b k else c)" |
63654 | 1269 |
show ?thesis |
1270 |
proof (cases "a \<in> S") |
|
1271 |
case False |
|
1272 |
then have "\<forall> k\<in> S. ?f k = c" by simp |
|
1273 |
with False show ?thesis by (simp add: setprod_constant) |
|
1274 |
next |
|
1275 |
case True |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1276 |
let ?A = "S - {a}" |
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1277 |
let ?B = "{a}" |
63654 | 1278 |
from True have eq: "S = ?A \<union> ?B" by blast |
1279 |
have disjoint: "?A \<inter> ?B = {}" by simp |
|
1280 |
from fin have fin': "finite ?A" "finite ?B" by auto |
|
1281 |
have f_A0: "setprod ?f ?A = setprod (\<lambda>i. c) ?A" |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1282 |
by (rule setprod.cong) auto |
63654 | 1283 |
from fin True have card_A: "card ?A = card S - 1" by auto |
1284 |
have f_A1: "setprod ?f ?A = c ^ card ?A" |
|
1285 |
unfolding f_A0 by (rule setprod_constant) |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1286 |
have "setprod ?f ?A * setprod ?f ?B = setprod ?f S" |
63654 | 1287 |
using setprod.union_disjoint[OF fin' disjoint, of ?f, unfolded eq[symmetric]] |
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1288 |
by simp |
63654 | 1289 |
with True card_A show ?thesis |
1290 |
by (simp add: f_A1 field_simps cong add: setprod.cong cong del: if_weak_cong) |
|
1291 |
qed |
|
62481
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1292 |
qed |
b5d8e57826df
tuned bootstrap order to provide type classes in a more sensible order
haftmann
parents:
62378
diff
changeset
|
1293 |
|
63952
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1294 |
lemma setsum_image_le: |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1295 |
fixes g :: "'a \<Rightarrow> 'b::ordered_ab_group_add" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1296 |
assumes "finite I" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g(f i)" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1297 |
shows "setsum g (f ` I) \<le> setsum (g \<circ> f) I" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1298 |
using assms |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1299 |
proof induction |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1300 |
case empty |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1301 |
then show ?case by auto |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1302 |
next |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1303 |
case (insert x F) then |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1304 |
have "setsum g (f ` insert x F) = setsum g (insert (f x) (f ` F))" by simp |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1305 |
also have "\<dots> \<le> g (f x) + setsum g (f ` F)" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1306 |
by (simp add: insert setsum.insert_if) |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1307 |
also have "\<dots> \<le> setsum (g \<circ> f) (insert x F)" |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1308 |
using insert by auto |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1309 |
finally show ?case . |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1310 |
qed |
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
1311 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
1312 |
end |