author | paulson <lp15@cam.ac.uk> |
Tue, 02 May 2023 12:51:05 +0100 | |
changeset 77934 | 01c88cf514fc |
parent 75669 | 43f5dfb7fa35 |
child 79492 | c1b0f64eb865 |
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 |
74979 | 11 |
imports Power Equiv_Relations |
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 |
|
70044
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
19 |
subsubsection \<open>Standard sum or product indexed by a finite set\<close> |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
20 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
21 |
interpretation comp_fun_commute f |
61169 | 22 |
by standard (simp add: fun_eq_iff left_commute) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
23 |
|
54745 | 24 |
interpretation comp?: comp_fun_commute "f \<circ> g" |
25 |
by (fact comp_comp_fun_commute) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
26 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
27 |
definition F :: "('b \<Rightarrow> 'a) \<Rightarrow> 'b set \<Rightarrow> 'a" |
63654 | 28 |
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
|
29 |
|
63654 | 30 |
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
|
31 |
by (simp add: eq_fold) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
32 |
|
63654 | 33 |
lemma empty [simp]: "F g {} = \<^bold>1" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
34 |
by (simp add: eq_fold) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
35 |
|
63654 | 36 |
lemma insert [simp]: "finite A \<Longrightarrow> x \<notin> A \<Longrightarrow> F g (insert x A) = g x \<^bold>* F g A" |
37 |
by (simp add: eq_fold) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
38 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
39 |
lemma remove: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
40 |
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
|
41 |
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
|
42 |
proof - |
63654 | 43 |
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
|
44 |
by (auto dest: mk_disjoint_insert) |
63654 | 45 |
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
|
46 |
ultimately show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
47 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
48 |
|
63654 | 49 |
lemma insert_remove: "finite A \<Longrightarrow> F g (insert x A) = g x \<^bold>* F g (A - {x})" |
50 |
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
|
51 |
|
63952
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents:
63938
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
|
63654 | 55 |
lemma neutral: "\<forall>x\<in>A. g x = \<^bold>1 \<Longrightarrow> F g A = \<^bold>1" |
56 |
by (induct A rule: infinite_finite_induct) simp_all |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
57 |
|
63654 | 58 |
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
|
59 |
by (simp add: neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
60 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
61 |
lemma union_inter: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
62 |
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
|
63 |
shows "F g (A \<union> B) \<^bold>* F g (A \<inter> B) = F g A \<^bold>* F g B" |
61799 | 64 |
\<comment> \<open>The reversed orientation looks more natural, but LOOPS as a simprule!\<close> |
63654 | 65 |
using assms |
66 |
proof (induct A) |
|
67 |
case empty |
|
68 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
69 |
next |
63654 | 70 |
case (insert x A) |
71 |
then show ?case |
|
72 |
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
|
73 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
74 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
75 |
corollary union_inter_neutral: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
76 |
assumes "finite A" and "finite B" |
63654 | 77 |
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
|
78 |
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
|
79 |
using assms by (simp add: union_inter [symmetric] neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
80 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
81 |
corollary union_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
82 |
assumes "finite A" and "finite B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
using assms by (simp add: union_inter_neutral) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
86 |
|
57418 | 87 |
lemma union_diff2: |
88 |
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
|
89 |
shows "F g (A \<union> B) = F g (A - B) \<^bold>* F g (B - A) \<^bold>* F g (A \<inter> B)" |
57418 | 90 |
proof - |
91 |
have "A \<union> B = A - B \<union> (B - A) \<union> A \<inter> B" |
|
92 |
by auto |
|
63654 | 93 |
with assms show ?thesis |
94 |
by simp (subst union_disjoint, auto)+ |
|
57418 | 95 |
qed |
96 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
97 |
lemma subset_diff: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
101 |
from assms have "finite (A - B)" by auto |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
102 |
moreover from assms have "finite B" by (rule finite_subset) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
103 |
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
|
104 |
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
|
105 |
moreover from assms have "A \<union> B = A" by auto |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
106 |
ultimately show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
107 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
108 |
|
70097
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents:
70045
diff
changeset
|
109 |
lemma Int_Diff: |
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents:
70045
diff
changeset
|
110 |
assumes "finite A" |
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents:
70045
diff
changeset
|
111 |
shows "F g A = F g (A \<inter> B) \<^bold>* F g (A - B)" |
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents:
70045
diff
changeset
|
112 |
by (subst subset_diff [where B = "A - B"]) (auto simp: Diff_Diff_Int assms) |
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents:
70045
diff
changeset
|
113 |
|
56545 | 114 |
lemma setdiff_irrelevant: |
115 |
assumes "finite A" |
|
116 |
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
|
117 |
using assms by (induct A) (simp_all add: insert_Diff_if) |
58195 | 118 |
|
56545 | 119 |
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
|
120 |
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
|
121 |
obtains a where "a \<in> A" and "g a \<noteq> \<^bold>1" |
56545 | 122 |
proof - |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
123 |
from assms have "\<exists>a\<in>A. g a \<noteq> \<^bold>1" |
56545 | 124 |
proof (induct A rule: infinite_finite_induct) |
63654 | 125 |
case infinite |
126 |
then show ?case by simp |
|
127 |
next |
|
128 |
case empty |
|
129 |
then show ?case by simp |
|
130 |
next |
|
56545 | 131 |
case (insert a A) |
63654 | 132 |
then show ?case by fastforce |
133 |
qed |
|
56545 | 134 |
with that show thesis by blast |
135 |
qed |
|
136 |
||
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
137 |
lemma reindex: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
138 |
assumes "inj_on h A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
139 |
shows "F g (h ` A) = F (g \<circ> h) A" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
140 |
proof (cases "finite A") |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
141 |
case True |
63654 | 142 |
with assms show ?thesis |
143 |
by (simp add: eq_fold fold_image comp_assoc) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
144 |
next |
63654 | 145 |
case False |
146 |
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
|
147 |
with False show ?thesis by simp |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
148 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
149 |
|
63357 | 150 |
lemma cong [fundef_cong]: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
151 |
assumes "A = B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
152 |
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
|
153 |
shows "F g A = F h B" |
60758 | 154 |
using g_h unfolding \<open>A = B\<close> |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
155 |
by (induct B rule: infinite_finite_induct) auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
156 |
|
69654 | 157 |
lemma cong_simp [cong]: |
69164 | 158 |
"\<lbrakk> A = B; \<And>x. x \<in> B =simp=> g x = h x \<rbrakk> \<Longrightarrow> F (\<lambda>x. g x) A = F (\<lambda>x. h x) B" |
159 |
by (rule cong) (simp_all add: simp_implies_def) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
160 |
|
57418 | 161 |
lemma reindex_cong: |
162 |
assumes "inj_on l B" |
|
163 |
assumes "A = l ` B" |
|
164 |
assumes "\<And>x. x \<in> B \<Longrightarrow> g (l x) = h x" |
|
165 |
shows "F g A = F h B" |
|
166 |
using assms by (simp add: reindex) |
|
167 |
||
72089
8348bba699e6
A new lemma about abstract Sum / Prod
paulson <lp15@cam.ac.uk>
parents:
71356
diff
changeset
|
168 |
lemma image_eq: |
8348bba699e6
A new lemma about abstract Sum / Prod
paulson <lp15@cam.ac.uk>
parents:
71356
diff
changeset
|
169 |
assumes "inj_on g A" |
8348bba699e6
A new lemma about abstract Sum / Prod
paulson <lp15@cam.ac.uk>
parents:
71356
diff
changeset
|
170 |
shows "F (\<lambda>x. x) (g ` A) = F g A" |
8348bba699e6
A new lemma about abstract Sum / Prod
paulson <lp15@cam.ac.uk>
parents:
71356
diff
changeset
|
171 |
using assms reindex_cong by fastforce |
8348bba699e6
A new lemma about abstract Sum / Prod
paulson <lp15@cam.ac.uk>
parents:
71356
diff
changeset
|
172 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
173 |
lemma UNION_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
174 |
assumes "finite I" and "\<forall>i\<in>I. finite (A i)" |
63654 | 175 |
and "\<forall>i\<in>I. \<forall>j\<in>I. i \<noteq> j \<longrightarrow> A i \<inter> A j = {}" |
69275 | 176 |
shows "F g (\<Union>(A ` I)) = F (\<lambda>x. F g (A x)) I" |
70128 | 177 |
using assms |
178 |
proof (induction rule: finite_induct) |
|
179 |
case (insert i I) |
|
180 |
then have "\<forall>j\<in>I. j \<noteq> i" |
|
181 |
by blast |
|
182 |
with insert.prems have "A i \<inter> \<Union>(A ` I) = {}" |
|
183 |
by blast |
|
184 |
with insert show ?case |
|
185 |
by (simp add: union_disjoint) |
|
186 |
qed auto |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
187 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
188 |
lemma Union_disjoint: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
189 |
assumes "\<forall>A\<in>C. finite A" "\<forall>A\<in>C. \<forall>B\<in>C. A \<noteq> B \<longrightarrow> A \<inter> B = {}" |
61952 | 190 |
shows "F g (\<Union>C) = (F \<circ> F) g C" |
63654 | 191 |
proof (cases "finite C") |
192 |
case True |
|
193 |
from UNION_disjoint [OF this assms] show ?thesis by simp |
|
194 |
next |
|
195 |
case False |
|
196 |
then show ?thesis by (auto dest: finite_UnionD intro: infinite) |
|
197 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
198 |
|
63654 | 199 |
lemma distrib: "F (\<lambda>x. g x \<^bold>* h x) A = F g A \<^bold>* F h A" |
63092 | 200 |
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
|
201 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
202 |
lemma Sigma: |
70128 | 203 |
assumes "finite A" "\<forall>x\<in>A. finite (B x)" |
204 |
shows "F (\<lambda>x. F (g x) (B x)) A = F (case_prod g) (SIGMA x:A. B x)" |
|
205 |
unfolding Sigma_def |
|
206 |
proof (subst UNION_disjoint) |
|
207 |
show "F (\<lambda>x. F (g x) (B x)) A = F (\<lambda>x. F (\<lambda>(x, y). g x y) (\<Union>y\<in>B x. {(x, y)})) A" |
|
208 |
proof (rule cong [OF refl]) |
|
209 |
show "F (g x) (B x) = F (\<lambda>(x, y). g x y) (\<Union>y\<in>B x. {(x, y)})" |
|
210 |
if "x \<in> A" for x |
|
211 |
using that assms by (simp add: UNION_disjoint) |
|
212 |
qed |
|
213 |
qed (use assms in auto) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
214 |
|
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
|
215 |
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
|
216 |
assumes Re: "R \<^bold>1 \<^bold>1" |
63654 | 217 |
and Rop: "\<forall>x1 y1 x2 y2. R x1 x2 \<and> R y1 y2 \<longrightarrow> R (x1 \<^bold>* y1) (x2 \<^bold>* y2)" |
218 |
and fin: "finite S" |
|
219 |
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
|
220 |
shows "R (F h S) (F g S)" |
63654 | 221 |
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
|
222 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
223 |
lemma mono_neutral_cong_left: |
63654 | 224 |
assumes "finite T" |
225 |
and "S \<subseteq> T" |
|
226 |
and "\<forall>i \<in> T - S. h i = \<^bold>1" |
|
227 |
and "\<And>x. x \<in> S \<Longrightarrow> g x = h x" |
|
228 |
shows "F g S = F h T" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
229 |
proof- |
60758 | 230 |
have eq: "T = S \<union> (T - S)" using \<open>S \<subseteq> T\<close> by blast |
231 |
have d: "S \<inter> (T - S) = {}" using \<open>S \<subseteq> T\<close> by blast |
|
232 |
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
|
233 |
by (auto intro: finite_subset) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
234 |
show ?thesis using assms(4) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
235 |
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
|
236 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
237 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
238 |
lemma mono_neutral_cong_right: |
63654 | 239 |
"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> |
240 |
F g T = F h S" |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
241 |
by (auto intro!: mono_neutral_cong_left [symmetric]) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
242 |
|
63654 | 243 |
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
|
244 |
by (blast intro: mono_neutral_cong_left) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
245 |
|
63654 | 246 |
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
|
247 |
by (blast intro!: mono_neutral_left [symmetric]) |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
248 |
|
64979
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
249 |
lemma mono_neutral_cong: |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
250 |
assumes [simp]: "finite T" "finite S" |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
251 |
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
|
252 |
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
|
253 |
shows "F g S = F h T" |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
254 |
proof- |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
255 |
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
|
256 |
by(rule mono_neutral_right)(auto intro: *) |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
257 |
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
|
258 |
also have "\<dots> = F h T" |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
259 |
by(rule mono_neutral_left)(auto intro: *) |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
260 |
finally show ?thesis . |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
261 |
qed |
20a623d03d71
move mono_neutral_cong from AFP/Deep_Learning/PP_Auxiliary
hoelzl
parents:
64272
diff
changeset
|
262 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
263 |
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
|
264 |
by (auto simp: bij_betw_def reindex) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
265 |
|
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
266 |
lemma reindex_bij_witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
267 |
assumes witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
268 |
"\<And>a. a \<in> S \<Longrightarrow> i (j a) = a" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
269 |
"\<And>a. a \<in> S \<Longrightarrow> j a \<in> T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
270 |
"\<And>b. b \<in> T \<Longrightarrow> j (i b) = b" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
271 |
"\<And>b. b \<in> T \<Longrightarrow> i b \<in> S" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
272 |
assumes eq: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
273 |
"\<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
|
274 |
shows "F g S = F h T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
275 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
276 |
have "bij_betw j S T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
277 |
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
|
278 |
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
|
279 |
by (intro cong) (auto simp: eq) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
280 |
ultimately show ?thesis |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
281 |
by (simp add: reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
282 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
283 |
|
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
284 |
lemma reindex_bij_betw_not_neutral: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
285 |
assumes fin: "finite S'" "finite T'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
286 |
assumes bij: "bij_betw h (S - S') (T - T')" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
287 |
assumes nn: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
288 |
"\<And>a. a \<in> S' \<Longrightarrow> g (h a) = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
289 |
"\<And>b. b \<in> T' \<Longrightarrow> g b = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
290 |
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
|
291 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
292 |
have [simp]: "finite S \<longleftrightarrow> finite T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
293 |
using bij_betw_finite[OF bij] fin by auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
294 |
show ?thesis |
63654 | 295 |
proof (cases "finite S") |
296 |
case True |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
297 |
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
|
298 |
by (intro mono_neutral_cong_right) auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
299 |
also have "\<dots> = F g (T - T')" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
300 |
using bij by (rule reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
301 |
also have "\<dots> = F g T" |
60758 | 302 |
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
|
303 |
finally show ?thesis . |
63654 | 304 |
next |
305 |
case False |
|
306 |
then show ?thesis by simp |
|
307 |
qed |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
308 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
309 |
|
57418 | 310 |
lemma reindex_nontrivial: |
311 |
assumes "finite A" |
|
63654 | 312 |
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 | 313 |
shows "F g (h ` A) = F (g \<circ> h) A" |
314 |
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
|
315 |
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 | 316 |
using nz by (auto intro!: inj_onI simp: bij_betw_def) |
63654 | 317 |
qed (use \<open>finite A\<close> in auto) |
57418 | 318 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
319 |
lemma reindex_bij_witness_not_neutral: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
320 |
assumes fin: "finite S'" "finite T'" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
321 |
assumes witness: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
322 |
"\<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
|
323 |
"\<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
|
324 |
"\<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
|
325 |
"\<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
|
326 |
assumes nn: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
327 |
"\<And>a. a \<in> S' \<Longrightarrow> g a = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
328 |
"\<And>b. b \<in> T' \<Longrightarrow> h b = z" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
329 |
assumes eq: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
330 |
"\<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
|
331 |
shows "F g S = F h T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
332 |
proof - |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
by (intro cong) (auto simp: eq) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
337 |
show ?thesis |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
338 |
unfolding F_eq using fin nn eq |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
339 |
by (intro reindex_bij_betw_not_neutral[OF _ _ bij]) auto |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
340 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56545
diff
changeset
|
341 |
|
67673
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
342 |
lemma delta_remove: |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
343 |
assumes fS: "finite S" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
344 |
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
|
345 |
proof - |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
346 |
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
|
347 |
show ?thesis |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
348 |
proof (cases "a \<in> S") |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
349 |
case False |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
350 |
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
|
351 |
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
|
352 |
next |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
353 |
case True |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
354 |
let ?A = "S - {a}" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
355 |
let ?B = "{a}" |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
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
|
361 |
with True show ?thesis |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
362 |
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
|
363 |
qed |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
364 |
qed |
c8caefb20564
lots of new material, ultimately related to measure theory
paulson <lp15@cam.ac.uk>
parents:
67511
diff
changeset
|
365 |
|
67683
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
366 |
lemma delta [simp]: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
367 |
assumes fS: "finite S" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
368 |
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
|
369 |
by (simp add: delta_remove [OF assms]) |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
370 |
|
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
371 |
lemma delta' [simp]: |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
372 |
assumes fin: "finite S" |
817944aeac3f
Lots of new material about matrices, etc.
paulson <lp15@cam.ac.uk>
parents:
67673
diff
changeset
|
373 |
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
|
374 |
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
|
375 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
376 |
lemma If_cases: |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
377 |
fixes P :: "'b \<Rightarrow> bool" and g h :: "'b \<Rightarrow> 'a" |
63654 | 378 |
assumes fin: "finite A" |
379 |
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
|
380 |
proof - |
63654 | 381 |
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
|
382 |
by blast+ |
63654 | 383 |
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
|
384 |
let ?g = "\<lambda>x. if P x then h x else g x" |
63654 | 385 |
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
|
386 |
by (subst (1 2) cong) simp_all |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
387 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
388 |
|
63654 | 389 |
lemma cartesian_product: "F (\<lambda>x. F (g x) B) A = F (case_prod g) (A \<times> B)" |
70128 | 390 |
proof (cases "A = {} \<or> B = {}") |
391 |
case True |
|
392 |
then show ?thesis |
|
393 |
by auto |
|
394 |
next |
|
395 |
case False |
|
396 |
then have "A \<noteq> {}" "B \<noteq> {}" by auto |
|
397 |
show ?thesis |
|
398 |
proof (cases "finite A \<and> finite B") |
|
399 |
case True |
|
400 |
then show ?thesis |
|
401 |
by (simp add: Sigma) |
|
402 |
next |
|
403 |
case False |
|
404 |
then consider "infinite A" | "infinite B" by auto |
|
405 |
then have "infinite (A \<times> B)" |
|
406 |
by cases (use \<open>A \<noteq> {}\<close> \<open>B \<noteq> {}\<close> in \<open>auto dest: finite_cartesian_productD1 finite_cartesian_productD2\<close>) |
|
407 |
then show ?thesis |
|
408 |
using False by auto |
|
409 |
qed |
|
410 |
qed |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
411 |
|
57418 | 412 |
lemma inter_restrict: |
413 |
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
|
414 |
shows "F g (A \<inter> B) = F (\<lambda>x. if x \<in> B then g x else \<^bold>1) A" |
57418 | 415 |
proof - |
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63092
diff
changeset
|
416 |
let ?g = "\<lambda>x. if x \<in> A \<inter> B then g x else \<^bold>1" |
63654 | 417 |
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 | 418 |
moreover have "A \<inter> B \<subseteq> A" by blast |
63654 | 419 |
ultimately have "F ?g (A \<inter> B) = F ?g A" |
420 |
using \<open>finite A\<close> by (intro mono_neutral_left) auto |
|
57418 | 421 |
then show ?thesis by simp |
422 |
qed |
|
423 |
||
424 |
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
|
425 |
"finite A \<Longrightarrow> F g {x \<in> A. P x} = F (\<lambda>x. if P x then g x else \<^bold>1) A" |
57418 | 426 |
by (simp add: inter_restrict [symmetric, of A "{x. P x}" g, simplified mem_Collect_eq] Int_def) |
427 |
||
428 |
lemma Union_comp: |
|
429 |
assumes "\<forall>A \<in> B. finite A" |
|
63654 | 430 |
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 | 431 |
shows "F g (\<Union>B) = (F \<circ> F) g B" |
63654 | 432 |
using assms |
433 |
proof (induct B rule: infinite_finite_induct) |
|
57418 | 434 |
case (infinite A) |
435 |
then have "\<not> finite (\<Union>A)" by (blast dest: finite_UnionD) |
|
436 |
with infinite show ?case by simp |
|
437 |
next |
|
63654 | 438 |
case empty |
439 |
then show ?case by simp |
|
57418 | 440 |
next |
441 |
case (insert A B) |
|
442 |
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
|
443 |
and "\<forall>x\<in>A \<inter> \<Union>B. g x = \<^bold>1" |
63654 | 444 |
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
|
445 |
then have "F g (A \<union> \<Union>B) = F g A \<^bold>* F g (\<Union>B)" |
57418 | 446 |
by (simp add: union_inter_neutral) |
60758 | 447 |
with \<open>finite B\<close> \<open>A \<notin> B\<close> show ?case |
57418 | 448 |
by (simp add: H) |
449 |
qed |
|
450 |
||
66804
3f9bb52082c4
avoid name clashes on interpretation of abstract locales
haftmann
parents:
66364
diff
changeset
|
451 |
lemma swap: "F (\<lambda>i. F (g i) B) A = F (\<lambda>j. F (\<lambda>i. g i j) A) B" |
57418 | 452 |
unfolding cartesian_product |
453 |
by (rule reindex_bij_witness [where i = "\<lambda>(i, j). (j, i)" and j = "\<lambda>(i, j). (j, i)"]) auto |
|
454 |
||
66804
3f9bb52082c4
avoid name clashes on interpretation of abstract locales
haftmann
parents:
66364
diff
changeset
|
455 |
lemma swap_restrict: |
57418 | 456 |
"finite A \<Longrightarrow> finite B \<Longrightarrow> |
457 |
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
|
458 |
by (simp add: inter_filter) (rule swap) |
57418 | 459 |
|
69510 | 460 |
lemma image_gen: |
461 |
assumes fin: "finite S" |
|
462 |
shows "F h S = F (\<lambda>y. F h {x. x \<in> S \<and> g x = y}) (g ` S)" |
|
463 |
proof - |
|
464 |
have "{y. y\<in> g`S \<and> g x = y} = {g x}" if "x \<in> S" for x |
|
465 |
using that by auto |
|
466 |
then have "F h S = F (\<lambda>x. F (\<lambda>y. h x) {y. y\<in> g`S \<and> g x = y}) S" |
|
467 |
by simp |
|
468 |
also have "\<dots> = F (\<lambda>y. F h {x. x \<in> S \<and> g x = y}) (g ` S)" |
|
469 |
by (rule swap_restrict [OF fin finite_imageI [OF fin]]) |
|
470 |
finally show ?thesis . |
|
471 |
qed |
|
472 |
||
473 |
lemma group: |
|
474 |
assumes fS: "finite S" and fT: "finite T" and fST: "g ` S \<subseteq> T" |
|
475 |
shows "F (\<lambda>y. F h {x. x \<in> S \<and> g x = y}) T = F h S" |
|
476 |
unfolding image_gen[OF fS, of h g] |
|
477 |
by (auto intro: neutral mono_neutral_right[OF fT fST]) |
|
478 |
||
57418 | 479 |
lemma Plus: |
480 |
fixes A :: "'b set" and B :: "'c set" |
|
481 |
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
|
482 |
shows "F g (A <+> B) = F (g \<circ> Inl) A \<^bold>* F (g \<circ> Inr) B" |
57418 | 483 |
proof - |
484 |
have "A <+> B = Inl ` A \<union> Inr ` B" by auto |
|
63654 | 485 |
moreover from fin have "finite (Inl ` A)" "finite (Inr ` B)" by auto |
486 |
moreover have "Inl ` A \<inter> Inr ` B = {}" by auto |
|
487 |
moreover have "inj_on Inl A" "inj_on Inr B" by (auto intro: inj_onI) |
|
488 |
ultimately show ?thesis |
|
489 |
using fin by (simp add: union_disjoint reindex) |
|
57418 | 490 |
qed |
491 |
||
58195 | 492 |
lemma same_carrier: |
493 |
assumes "finite C" |
|
494 |
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
|
495 |
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 | 496 |
shows "F g A = F h B \<longleftrightarrow> F g C = F h C" |
497 |
proof - |
|
63654 | 498 |
have "finite A" and "finite B" and "finite (C - A)" and "finite (C - B)" |
499 |
using \<open>finite C\<close> subset by (auto elim: finite_subset) |
|
58195 | 500 |
from subset have [simp]: "A - (C - A) = A" by auto |
501 |
from subset have [simp]: "B - (C - B) = B" by auto |
|
502 |
from subset have "C = A \<union> (C - A)" by auto |
|
503 |
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
|
504 |
also have "\<dots> = F g (A - (C - A)) \<^bold>* F g (C - A - A) \<^bold>* F g (A \<inter> (C - A))" |
60758 | 505 |
using \<open>finite A\<close> \<open>finite (C - A)\<close> by (simp only: union_diff2) |
63654 | 506 |
finally have *: "F g C = F g A" using trivial by simp |
58195 | 507 |
from subset have "C = B \<union> (C - B)" by auto |
508 |
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
|
509 |
also have "\<dots> = F h (B - (C - B)) \<^bold>* F h (C - B - B) \<^bold>* F h (B \<inter> (C - B))" |
60758 | 510 |
using \<open>finite B\<close> \<open>finite (C - B)\<close> by (simp only: union_diff2) |
63654 | 511 |
finally have "F h C = F h B" |
512 |
using trivial by simp |
|
513 |
with * show ?thesis by simp |
|
58195 | 514 |
qed |
515 |
||
516 |
lemma same_carrierI: |
|
517 |
assumes "finite C" |
|
518 |
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
|
519 |
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 | 520 |
assumes "F g C = F h C" |
521 |
shows "F g A = F h B" |
|
522 |
using assms same_carrier [of C A B] by simp |
|
523 |
||
69700
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
524 |
lemma eq_general: |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
525 |
assumes B: "\<And>y. y \<in> B \<Longrightarrow> \<exists>!x. x \<in> A \<and> h x = y" and A: "\<And>x. x \<in> A \<Longrightarrow> h x \<in> B \<and> \<gamma>(h x) = \<phi> x" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
526 |
shows "F \<phi> A = F \<gamma> B" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
527 |
proof - |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
528 |
have eq: "B = h ` A" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
529 |
by (auto dest: assms) |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
530 |
have h: "inj_on h A" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
531 |
using assms by (blast intro: inj_onI) |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
532 |
have "F \<phi> A = F (\<gamma> \<circ> h) A" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
533 |
using A by auto |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
534 |
also have "\<dots> = F \<gamma> B" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
535 |
by (simp add: eq reindex h) |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
536 |
finally show ?thesis . |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
537 |
qed |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
538 |
|
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
539 |
lemma eq_general_inverses: |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
540 |
assumes B: "\<And>y. y \<in> B \<Longrightarrow> k y \<in> A \<and> h(k y) = y" and A: "\<And>x. x \<in> A \<Longrightarrow> h x \<in> B \<and> k(h x) = x \<and> \<gamma>(h x) = \<phi> x" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
541 |
shows "F \<phi> A = F \<gamma> B" |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
542 |
by (rule eq_general [where h=h]) (force intro: dest: A B)+ |
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69654
diff
changeset
|
543 |
|
70044
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
544 |
subsubsection \<open>HOL Light variant: sum/product indexed by the non-neutral subset\<close> |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
545 |
text \<open>NB only a subset of the properties above are proved\<close> |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
546 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
547 |
definition G :: "['b \<Rightarrow> 'a,'b set] \<Rightarrow> 'a" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
548 |
where "G p I \<equiv> if finite {x \<in> I. p x \<noteq> \<^bold>1} then F p {x \<in> I. p x \<noteq> \<^bold>1} else \<^bold>1" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
549 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
550 |
lemma finite_Collect_op: |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
551 |
shows "\<lbrakk>finite {i \<in> I. x i \<noteq> \<^bold>1}; finite {i \<in> I. y i \<noteq> \<^bold>1}\<rbrakk> \<Longrightarrow> finite {i \<in> I. x i \<^bold>* y i \<noteq> \<^bold>1}" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
552 |
apply (rule finite_subset [where B = "{i \<in> I. x i \<noteq> \<^bold>1} \<union> {i \<in> I. y i \<noteq> \<^bold>1}"]) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
553 |
using left_neutral by force+ |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
554 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
555 |
lemma empty' [simp]: "G p {} = \<^bold>1" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
556 |
by (auto simp: G_def) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
557 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
558 |
lemma eq_sum [simp]: "finite I \<Longrightarrow> G p I = F p I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
559 |
by (auto simp: G_def intro: mono_neutral_cong_left) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
560 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
561 |
lemma insert' [simp]: |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
562 |
assumes "finite {x \<in> I. p x \<noteq> \<^bold>1}" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
563 |
shows "G p (insert i I) = (if i \<in> I then G p I else p i \<^bold>* G p I)" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
564 |
proof - |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
565 |
have "{x. x = i \<and> p x \<noteq> \<^bold>1 \<or> x \<in> I \<and> p x \<noteq> \<^bold>1} = (if p i = \<^bold>1 then {x \<in> I. p x \<noteq> \<^bold>1} else insert i {x \<in> I. p x \<noteq> \<^bold>1})" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
566 |
by auto |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
567 |
then show ?thesis |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
568 |
using assms by (simp add: G_def conj_disj_distribR insert_absorb) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
569 |
qed |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
570 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
571 |
lemma distrib_triv': |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
572 |
assumes "finite I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
573 |
shows "G (\<lambda>i. g i \<^bold>* h i) I = G g I \<^bold>* G h I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
574 |
by (simp add: assms local.distrib) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
575 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
576 |
lemma non_neutral': "G g {x \<in> I. g x \<noteq> \<^bold>1} = G g I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
577 |
by (simp add: G_def) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
578 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
579 |
lemma distrib': |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
580 |
assumes "finite {x \<in> I. g x \<noteq> \<^bold>1}" "finite {x \<in> I. h x \<noteq> \<^bold>1}" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
581 |
shows "G (\<lambda>i. g i \<^bold>* h i) I = G g I \<^bold>* G h I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
582 |
proof - |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
583 |
have "a \<^bold>* a \<noteq> a \<Longrightarrow> a \<noteq> \<^bold>1" for a |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
584 |
by auto |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
585 |
then have "G (\<lambda>i. g i \<^bold>* h i) I = G (\<lambda>i. g i \<^bold>* h i) ({i \<in> I. g i \<noteq> \<^bold>1} \<union> {i \<in> I. h i \<noteq> \<^bold>1})" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
586 |
using assms by (force simp: G_def finite_Collect_op intro!: mono_neutral_cong) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
587 |
also have "\<dots> = G g I \<^bold>* G h I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
588 |
proof - |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
589 |
have "F g ({i \<in> I. g i \<noteq> \<^bold>1} \<union> {i \<in> I. h i \<noteq> \<^bold>1}) = G g I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
590 |
"F h ({i \<in> I. g i \<noteq> \<^bold>1} \<union> {i \<in> I. h i \<noteq> \<^bold>1}) = G h I" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
591 |
by (auto simp: G_def assms intro: mono_neutral_right) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
592 |
then show ?thesis |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
593 |
using assms by (simp add: distrib) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
594 |
qed |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
595 |
finally show ?thesis . |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
596 |
qed |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
597 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
598 |
lemma cong': |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
599 |
assumes "A = B" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
600 |
assumes g_h: "\<And>x. x \<in> B \<Longrightarrow> g x = h x" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
601 |
shows "G g A = G h B" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
602 |
using assms by (auto simp: G_def cong: conj_cong intro: cong) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
603 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
604 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
605 |
lemma mono_neutral_cong_left': |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
606 |
assumes "S \<subseteq> T" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
607 |
and "\<And>i. i \<in> T - S \<Longrightarrow> h i = \<^bold>1" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
608 |
and "\<And>x. x \<in> S \<Longrightarrow> g x = h x" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
609 |
shows "G g S = G h T" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
610 |
proof - |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
611 |
have *: "{x \<in> S. g x \<noteq> \<^bold>1} = {x \<in> T. h x \<noteq> \<^bold>1}" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
612 |
using assms by (metis DiffI subset_eq) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
613 |
then have "finite {x \<in> S. g x \<noteq> \<^bold>1} = finite {x \<in> T. h x \<noteq> \<^bold>1}" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
614 |
by simp |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
615 |
then show ?thesis |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
616 |
using assms by (auto simp add: G_def * intro: cong) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
617 |
qed |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
618 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
619 |
lemma mono_neutral_cong_right': |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
620 |
"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> |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
621 |
G g T = G h S" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
622 |
by (auto intro!: mono_neutral_cong_left' [symmetric]) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
623 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
624 |
lemma mono_neutral_left': "S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. g i = \<^bold>1 \<Longrightarrow> G g S = G g T" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
625 |
by (blast intro: mono_neutral_cong_left') |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
626 |
|
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
627 |
lemma mono_neutral_right': "S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. g i = \<^bold>1 \<Longrightarrow> G g T = G g S" |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
628 |
by (blast intro!: mono_neutral_left' [symmetric]) |
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
629 |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
630 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
631 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
632 |
|
60758 | 633 |
subsection \<open>Generalized summation over a set\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
634 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
635 |
context comm_monoid_add |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
636 |
begin |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
637 |
|
64267 | 638 |
sublocale sum: comm_monoid_set plus 0 |
70044
da5857dbcbb9
More group theory. Sum and product indexed by the non-neutral part of a set
paulson <lp15@cam.ac.uk>
parents:
69802
diff
changeset
|
639 |
defines sum = sum.F and sum' = sum.G .. |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
640 |
|
69767
d10fafeb93c0
less special syntax: make \<Sum> an ordinary function symbol
nipkow
parents:
69700
diff
changeset
|
641 |
abbreviation Sum ("\<Sum>") |
d10fafeb93c0
less special syntax: make \<Sum> an ordinary function symbol
nipkow
parents:
69700
diff
changeset
|
642 |
where "\<Sum> \<equiv> sum (\<lambda>x. x)" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
643 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
644 |
end |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
645 |
|
69593 | 646 |
text \<open>Now: lots of fancy syntax. First, \<^term>\<open>sum (\<lambda>x. e) A\<close> is written \<open>\<Sum>x\<in>A. e\<close>.\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
647 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
648 |
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
|
649 |
"_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
|
650 |
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
|
651 |
"_sum" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b::comm_monoid_add" ("(2\<Sum>(_/\<in>_)./ _)" [0, 51, 10] 10) |
61799 | 652 |
translations \<comment> \<open>Beware of argument permutation!\<close> |
64267 | 653 |
"\<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
|
654 |
|
69593 | 655 |
text \<open>Instead of \<^term>\<open>\<Sum>x\<in>{x. P}. e\<close> 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
|
656 |
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61952
diff
changeset
|
657 |
syntax (ASCII) |
64267 | 658 |
"_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
|
659 |
syntax |
64267 | 660 |
"_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
|
661 |
translations |
64267 | 662 |
"\<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
|
663 |
|
60758 | 664 |
print_translation \<open> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
665 |
let |
69593 | 666 |
fun sum_tr' [Abs (x, Tx, t), Const (\<^const_syntax>\<open>Collect\<close>, _) $ Abs (y, Ty, P)] = |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
667 |
if x <> y then raise Match |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
668 |
else |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
669 |
let |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
670 |
val x' = Syntax_Trans.mark_bound_body (x, Tx); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
671 |
val t' = subst_bound (x', t); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
672 |
val P' = subst_bound (x', P); |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
673 |
in |
69593 | 674 |
Syntax.const \<^syntax_const>\<open>_qsum\<close> $ Syntax_Trans.mark_bound_abs (x, Tx) $ P' $ t' |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
675 |
end |
64267 | 676 |
| sum_tr' _ = raise Match; |
69593 | 677 |
in [(\<^const_syntax>\<open>sum\<close>, K sum_tr')] end |
60758 | 678 |
\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
679 |
|
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
680 |
|
60758 | 681 |
subsubsection \<open>Properties in more restricted classes of structures\<close> |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
682 |
|
64267 | 683 |
lemma sum_Un: |
684 |
"finite A \<Longrightarrow> finite B \<Longrightarrow> sum f (A \<union> B) = sum f A + sum f B - sum f (A \<inter> B)" |
|
63654 | 685 |
for f :: "'b \<Rightarrow> 'a::ab_group_add" |
64267 | 686 |
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
|
687 |
|
64267 | 688 |
lemma sum_Un2: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
689 |
assumes "finite (A \<union> B)" |
64267 | 690 |
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
|
691 |
proof - |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
692 |
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
|
693 |
by auto |
63654 | 694 |
with assms show ?thesis |
64267 | 695 |
by simp (subst sum.union_disjoint, auto)+ |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
696 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
697 |
|
75461
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
698 |
(*Like sum.subset_diff but expressed perhaps more conveniently using subtraction*) |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
699 |
lemma sum_diff: |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
700 |
fixes f :: "'b \<Rightarrow> 'a::ab_group_add" |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
701 |
assumes "finite A" "B \<subseteq> A" |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
702 |
shows "sum f (A - B) = sum f A - sum f B" |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
703 |
using sum.subset_diff [of B A f] assms by simp |
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
704 |
|
64267 | 705 |
lemma sum_diff1: |
63654 | 706 |
fixes f :: "'b \<Rightarrow> 'a::ab_group_add" |
707 |
assumes "finite A" |
|
64267 | 708 |
shows "sum f (A - {a}) = (if a \<in> A then sum f A - f a else sum f A)" |
75461
4c3bc0d2568f
Eliminated two unnecessary inductions
paulson <lp15@cam.ac.uk>
parents:
75078
diff
changeset
|
709 |
using assms by (simp add: sum_diff) |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
710 |
|
70045
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
711 |
lemma sum_diff1'_aux: |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
712 |
fixes f :: "'a \<Rightarrow> 'b::ab_group_add" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
713 |
assumes "finite F" "{i \<in> I. f i \<noteq> 0} \<subseteq> F" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
714 |
shows "sum' f (I - {i}) = (if i \<in> I then sum' f I - f i else sum' f I)" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
715 |
using assms |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
716 |
proof induct |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
717 |
case (insert x F) |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
718 |
have 1: "finite {x \<in> I. f x \<noteq> 0} \<Longrightarrow> finite {x \<in> I. x \<noteq> i \<and> f x \<noteq> 0}" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
719 |
by (erule rev_finite_subset) auto |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
720 |
have 2: "finite {x \<in> I. x \<noteq> i \<and> f x \<noteq> 0} \<Longrightarrow> finite {x \<in> I. f x \<noteq> 0}" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
721 |
apply (drule finite_insert [THEN iffD2]) |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
722 |
by (erule rev_finite_subset) auto |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
723 |
have 3: "finite {i \<in> I. f i \<noteq> 0}" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
724 |
using finite_subset insert by blast |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
725 |
show ?case |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
726 |
using insert sum_diff1 [of "{i \<in> I. f i \<noteq> 0}" f i] |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
727 |
by (auto simp: sum.G_def 1 2 3 set_diff_eq conj_ac) |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
728 |
qed (simp add: sum.G_def) |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
729 |
|
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
730 |
lemma sum_diff1': |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
731 |
fixes f :: "'a \<Rightarrow> 'b::ab_group_add" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
732 |
assumes "finite {i \<in> I. f i \<noteq> 0}" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
733 |
shows "sum' f (I - {i}) = (if i \<in> I then sum' f I - f i else sum' f I)" |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
734 |
by (rule sum_diff1'_aux [OF assms order_refl]) |
7b6add80e3a5
fixed markup in Poly_Mapping; Free_Abelian_Groups (but not yet imported by Algebra!)
paulson <lp15@cam.ac.uk>
parents:
70044
diff
changeset
|
735 |
|
64267 | 736 |
lemma (in ordered_comm_monoid_add) sum_mono: |
63915 | 737 |
"(\<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)" |
738 |
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
|
739 |
|
64267 | 740 |
lemma (in strict_ordered_comm_monoid_add) sum_strict_mono: |
63654 | 741 |
assumes "finite A" "A \<noteq> {}" |
742 |
and "\<And>x. x \<in> A \<Longrightarrow> f x < g x" |
|
64267 | 743 |
shows "sum f A < sum g A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
744 |
using assms |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
745 |
proof (induct rule: finite_ne_induct) |
63654 | 746 |
case singleton |
747 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
748 |
next |
63654 | 749 |
case insert |
750 |
then show ?case by (auto simp: add_strict_mono) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
751 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
752 |
|
64267 | 753 |
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
|
754 |
fixes f g :: "'i \<Rightarrow> 'a::ordered_cancel_comm_monoid_add" |
63654 | 755 |
assumes "finite A" |
756 |
and "\<forall>x\<in>A. f x \<le> g x" |
|
757 |
and "\<exists>a\<in>A. f a < g a" |
|
64267 | 758 |
shows "sum f A < sum g A" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
759 |
proof- |
63654 | 760 |
from assms(3) obtain a where a: "a \<in> A" "f a < g a" by blast |
64267 | 761 |
have "sum f A = sum f ((A - {a}) \<union> {a})" |
63654 | 762 |
by(simp add: insert_absorb[OF \<open>a \<in> A\<close>]) |
64267 | 763 |
also have "\<dots> = sum f (A - {a}) + sum f {a}" |
764 |
using \<open>finite A\<close> by(subst sum.union_disjoint) auto |
|
765 |
also have "sum f (A - {a}) \<le> sum g (A - {a})" |
|
766 |
by (rule sum_mono) (simp add: assms(2)) |
|
767 |
also from a have "sum f {a} < sum g {a}" by simp |
|
768 |
also have "sum g (A - {a}) + sum g {a} = sum g((A - {a}) \<union> {a})" |
|
769 |
using \<open>finite A\<close> by (subst sum.union_disjoint[symmetric]) auto |
|
770 |
also have "\<dots> = sum g A" by (simp add: insert_absorb[OF \<open>a \<in> A\<close>]) |
|
63654 | 771 |
finally show ?thesis |
772 |
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
|
773 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
774 |
|
64267 | 775 |
lemma sum_mono_inv: |
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
776 |
fixes f g :: "'i \<Rightarrow> 'a :: ordered_cancel_comm_monoid_add" |
64267 | 777 |
assumes eq: "sum f I = sum g I" |
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
778 |
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
|
779 |
assumes i: "i \<in> I" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
780 |
assumes I: "finite I" |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
781 |
shows "f i = g i" |
63654 | 782 |
proof (rule ccontr) |
783 |
assume "\<not> ?thesis" |
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
784 |
with le[OF i] have "f i < g i" by simp |
63654 | 785 |
with i have "\<exists>i\<in>I. f i < g i" .. |
64267 | 786 |
from sum_strict_mono_ex1[OF I _ this] le have "sum f I < sum g I" |
63654 | 787 |
by blast |
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
788 |
with eq show False by simp |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
789 |
qed |
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63357
diff
changeset
|
790 |
|
64267 | 791 |
lemma member_le_sum: |
63938 | 792 |
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
|
793 |
assumes "i \<in> A" |
0e640e04fc56
New theorems; stronger theorems; tidier theorems. Also some renaming
paulson <lp15@cam.ac.uk>
parents:
66089
diff
changeset
|
794 |
and le: "\<And>x. x \<in> A - {i} \<Longrightarrow> 0 \<le> f x" |
63938 | 795 |
and "finite A" |
64267 | 796 |
shows "f i \<le> sum f A" |
63938 | 797 |
proof - |
64267 | 798 |
have "f i \<le> sum f (A \<inter> {i})" |
63938 | 799 |
by (simp add: assms) |
800 |
also have "... = (\<Sum>x\<in>A. if x \<in> {i} then f x else 0)" |
|
64267 | 801 |
using assms sum.inter_restrict by blast |
802 |
also have "... \<le> sum f A" |
|
803 |
apply (rule sum_mono) |
|
63938 | 804 |
apply (auto simp: le) |
805 |
done |
|
806 |
finally show ?thesis . |
|
807 |
qed |
|
808 |
||
64267 | 809 |
lemma sum_negf: "(\<Sum>x\<in>A. - f x) = - (\<Sum>x\<in>A. f x)" |
63654 | 810 |
for f :: "'b \<Rightarrow> 'a::ab_group_add" |
63915 | 811 |
by (induct A rule: infinite_finite_induct) auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
812 |
|
64267 | 813 |
lemma sum_subtractf: "(\<Sum>x\<in>A. f x - g x) = (\<Sum>x\<in>A. f x) - (\<Sum>x\<in>A. g x)" |
63654 | 814 |
for f g :: "'b \<Rightarrow>'a::ab_group_add" |
64267 | 815 |
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
|
816 |
|
64267 | 817 |
lemma sum_subtractf_nat: |
63654 | 818 |
"(\<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)" |
819 |
for f g :: "'a \<Rightarrow> nat" |
|
64267 | 820 |
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
|
821 |
|
63654 | 822 |
context ordered_comm_monoid_add |
823 |
begin |
|
824 |
||
65680
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
paulson <lp15@cam.ac.uk>
parents:
64979
diff
changeset
|
825 |
lemma sum_nonneg: "(\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x) \<Longrightarrow> 0 \<le> sum f A" |
63915 | 826 |
proof (induct A rule: infinite_finite_induct) |
827 |
case infinite |
|
828 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
829 |
next |
63915 | 830 |
case empty |
831 |
then show ?case by simp |
|
832 |
next |
|
833 |
case (insert x F) |
|
64267 | 834 |
then have "0 + 0 \<le> f x + sum f F" by (blast intro: add_mono) |
63915 | 835 |
with insert show ?case by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
836 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
837 |
|
65680
378a2f11bec9
Simplification of some proofs. Also key lemmas using !! rather than ! in premises
paulson <lp15@cam.ac.uk>
parents:
64979
diff
changeset
|
838 |
lemma sum_nonpos: "(\<And>x. x \<in> A \<Longrightarrow> f x \<le> 0) \<Longrightarrow> sum f A \<le> 0" |
63915 | 839 |
proof (induct A rule: infinite_finite_induct) |
840 |
case infinite |
|
841 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
842 |
next |
63915 | 843 |
case empty |
844 |
then show ?case by simp |
|
845 |
next |
|
846 |
case (insert x F) |
|
64267 | 847 |
then have "f x + sum f F \<le> 0 + 0" by (blast intro: add_mono) |
63915 | 848 |
with insert show ?case by simp |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
849 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
850 |
|
64267 | 851 |
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
|
852 |
"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 | 853 |
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
|
854 |
|
64267 | 855 |
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
|
856 |
"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 | 857 |
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
|
858 |
|
64267 | 859 |
lemma sum_nonneg_leq_bound: |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
860 |
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
|
861 |
shows "f i \<le> B" |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
862 |
proof - |
63654 | 863 |
from assms have "f i \<le> f i + (\<Sum>i \<in> s - {i}. f i)" |
64267 | 864 |
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
|
865 |
also have "\<dots> = B" |
64267 | 866 |
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
|
867 |
finally show ?thesis by auto |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
868 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
869 |
|
64267 | 870 |
lemma sum_mono2: |
63654 | 871 |
assumes fin: "finite B" |
872 |
and sub: "A \<subseteq> B" |
|
873 |
and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b" |
|
64267 | 874 |
shows "sum f A \<le> sum f B" |
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
875 |
proof - |
64267 | 876 |
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
|
877 |
by (auto intro: add_increasing2 [OF sum_nonneg] nn) |
64267 | 878 |
also from fin finite_subset[OF sub fin] have "\<dots> = sum f (A \<union> (B-A))" |
879 |
by (simp add: sum.union_disjoint del: Un_Diff_cancel) |
|
63654 | 880 |
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
|
881 |
finally show ?thesis . |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
882 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
883 |
|
64267 | 884 |
lemma sum_le_included: |
57418 | 885 |
assumes "finite s" "finite t" |
886 |
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 | 887 |
shows "sum f s \<le> sum g t" |
57418 | 888 |
proof - |
64267 | 889 |
have "sum f s \<le> sum (\<lambda>y. sum g {x. x\<in>t \<and> i x = y}) s" |
890 |
proof (rule sum_mono) |
|
63654 | 891 |
fix y |
892 |
assume "y \<in> s" |
|
57418 | 893 |
with assms obtain z where z: "z \<in> t" "y = i z" "f y \<le> g z" by auto |
64267 | 894 |
with assms show "f y \<le> sum g {x \<in> t. i x = y}" (is "?A y \<le> ?B y") |
895 |
using order_trans[of "?A (i z)" "sum g {z}" "?B (i z)", intro] |
|
896 |
by (auto intro!: sum_mono2) |
|
57418 | 897 |
qed |
64267 | 898 |
also have "\<dots> \<le> sum (\<lambda>y. sum g {x. x\<in>t \<and> i x = y}) (i ` t)" |
899 |
using assms(2-4) by (auto intro!: sum_mono2 sum_nonneg) |
|
900 |
also have "\<dots> \<le> sum g t" |
|
69510 | 901 |
using assms by (auto simp: sum.image_gen[symmetric]) |
57418 | 902 |
finally show ?thesis . |
903 |
qed |
|
904 |
||
63654 | 905 |
end |
906 |
||
64267 | 907 |
lemma (in canonically_ordered_monoid_add) sum_eq_0_iff [simp]: |
908 |
"finite F \<Longrightarrow> (sum f F = 0) = (\<forall>a\<in>F. f a = 0)" |
|
909 |
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
|
910 |
|
66936 | 911 |
context semiring_0 |
912 |
begin |
|
913 |
||
914 |
lemma sum_distrib_left: "r * sum f A = (\<Sum>n\<in>A. r * f n)" |
|
915 |
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
|
916 |
|
64267 | 917 |
lemma sum_distrib_right: "sum f A * r = (\<Sum>n\<in>A. f n * r)" |
66936 | 918 |
by (induct A rule: infinite_finite_induct) (simp_all add: algebra_simps) |
919 |
||
920 |
end |
|
63654 | 921 |
|
64267 | 922 |
lemma sum_divide_distrib: "sum f A / r = (\<Sum>n\<in>A. f n / r)" |
63654 | 923 |
for r :: "'a::field" |
63915 | 924 |
proof (induct A rule: infinite_finite_induct) |
925 |
case infinite |
|
926 |
then show ?case by simp |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
927 |
next |
63915 | 928 |
case empty |
929 |
then show ?case by simp |
|
930 |
next |
|
931 |
case insert |
|
932 |
then show ?case by (simp add: add_divide_distrib) |
|
54744
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
933 |
qed |
1e7f2d296e19
more algebraic terminology for theories about big operators
haftmann
parents:
diff
changeset
|
934 |
|
64267 | 935 |
lemma sum_abs[iff]: "\<bar>sum f A\<bar> \<le> sum (\<lambda>i. \<bar>f i\<bar>) A" |
63654 | 936 |
for f :: "'a \<Rightarrow> 'b::ordered_ab_group_add_abs" |
63915 | 937 |
proof (induct A rule: infinite_finite_induct) |