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