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