7998
|
1 |
(*
|
|
2 |
Sums with naturals as index domain
|
|
3 |
$Id$
|
|
4 |
Author: Clemens Ballarin, started 12 December 1996
|
|
5 |
*)
|
|
6 |
|
|
7 |
section "Basic Properties";
|
|
8 |
|
|
9 |
Goalw [SUM_def] "SUM 0 f = (f 0::'a::ring)";
|
|
10 |
by (Asm_simp_tac 1);
|
|
11 |
qed "SUM_0";
|
|
12 |
|
|
13 |
Goalw [SUM_def]
|
|
14 |
"SUM (Suc n) f = (f (Suc n) + SUM n f::'a::ring)";
|
|
15 |
by (Simp_tac 1);
|
|
16 |
qed "SUM_Suc";
|
|
17 |
|
|
18 |
Addsimps [SUM_0, SUM_Suc];
|
|
19 |
|
|
20 |
Goal
|
|
21 |
"SUM (Suc n) f = (SUM n (%i. f (Suc i)) + f 0::'a::ring)";
|
8707
|
22 |
by (induct_tac "n" 1);
|
7998
|
23 |
(* Base case *)
|
|
24 |
by (Simp_tac 1);
|
|
25 |
(* Induction step *)
|
|
26 |
by (asm_full_simp_tac (simpset() addsimps [a_assoc]) 1);
|
|
27 |
qed "SUM_Suc2";
|
|
28 |
|
|
29 |
(* Congruence rules *)
|
|
30 |
|
|
31 |
val [p_equal, p_context] = goal NatSum.thy
|
|
32 |
"[| m = n; !!i. i <= n ==> f i = g i |] ==> SUM m f = (SUM n g::'a::ring)";
|
|
33 |
by (simp_tac (simpset() addsimps [p_equal]) 1);
|
|
34 |
by (cut_inst_tac [("n", "n")] le_refl 1);
|
|
35 |
by (etac rev_mp 1);
|
|
36 |
by (res_inst_tac [("P", "%k. k <= n --> SUM k f = SUM k g")] nat_induct 1);
|
|
37 |
(* Base case *)
|
|
38 |
by (simp_tac (simpset() addsimps [p_context]) 1);
|
|
39 |
(* Induction step *)
|
|
40 |
by (rtac impI 1);
|
|
41 |
by (etac impE 1);
|
|
42 |
by (rtac Suc_leD 1);
|
|
43 |
by (assume_tac 1);
|
|
44 |
by (asm_simp_tac (simpset() addsimps [p_context]) 1);
|
|
45 |
qed "SUM_cong";
|
|
46 |
|
|
47 |
Addcongs [SUM_cong];
|
|
48 |
|
|
49 |
(* Results needed for the development of polynomials *)
|
|
50 |
|
|
51 |
section "Ring Properties";
|
|
52 |
|
|
53 |
Goal "SUM n (%i. <0>) = (<0>::'a::ring)";
|
8707
|
54 |
by (induct_tac "n" 1);
|
7998
|
55 |
by (Simp_tac 1);
|
|
56 |
by (Asm_simp_tac 1);
|
|
57 |
qed "SUM_zero";
|
|
58 |
|
|
59 |
Addsimps [SUM_zero];
|
|
60 |
|
|
61 |
Goal
|
|
62 |
"!!f::nat=>'a::ring. SUM n (%i. f i + g i) = SUM n f + SUM n g";
|
8707
|
63 |
by (induct_tac "n" 1);
|
7998
|
64 |
(* Base case *)
|
|
65 |
by (Simp_tac 1);
|
|
66 |
(* Induction step *)
|
|
67 |
by (asm_simp_tac (simpset() addsimps a_ac) 1);
|
|
68 |
qed "SUM_add";
|
|
69 |
|
|
70 |
Goal
|
|
71 |
"!!a::'a::ring. SUM n f * a = SUM n (%i. f i * a)";
|
8707
|
72 |
by (induct_tac "n" 1);
|
7998
|
73 |
(* Base case *)
|
|
74 |
by (Simp_tac 1);
|
|
75 |
(* Induction step *)
|
|
76 |
by (asm_simp_tac (simpset() addsimps [l_distr]) 1);
|
|
77 |
qed "SUM_ldistr";
|
|
78 |
|
|
79 |
Goal
|
|
80 |
"!!a::'a::ring. a * SUM n f = SUM n (%i. a * f i)";
|
8707
|
81 |
by (induct_tac "n" 1);
|
7998
|
82 |
(* Base case *)
|
|
83 |
by (Simp_tac 1);
|
|
84 |
(* Induction step *)
|
|
85 |
by (asm_simp_tac (simpset() addsimps [r_distr]) 1);
|
|
86 |
qed "SUM_rdistr";
|
|
87 |
|
|
88 |
section "Results for the Construction of Polynomials";
|
|
89 |
|
8738
|
90 |
Goal "[| m <= j; Suc j <= n |] ==> (n - m) - Suc (j - m) = n - Suc j";
|
|
91 |
by (asm_simp_tac (simpset() addsplits [nat_diff_split']) 1);
|
7998
|
92 |
qed "Suc_diff_lemma";
|
|
93 |
|
|
94 |
Goal
|
|
95 |
"!!a::nat=>'a::ring. k <= n --> \
|
|
96 |
\ SUM k (%j. SUM j (%i. a i * b (j-i)) * c (n-j)) = \
|
|
97 |
\ SUM k (%j. a j * SUM (k-j) (%i. b i * c (n-j-i)))";
|
8707
|
98 |
by (induct_tac "k" 1);
|
7998
|
99 |
(* Base case *)
|
|
100 |
by (simp_tac (simpset() addsimps [m_assoc]) 1);
|
|
101 |
(* Induction step *)
|
|
102 |
by (rtac impI 1);
|
|
103 |
by (etac impE 1);
|
|
104 |
by (rtac Suc_leD 1);
|
|
105 |
by (assume_tac 1);
|
8738
|
106 |
by (asm_simp_tac
|
|
107 |
(simpset() addsimps a_ac@
|
|
108 |
[Suc_diff_le, l_distr, r_distr, m_assoc, SUM_add]) 1);
|
|
109 |
by (asm_simp_tac
|
|
110 |
(simpset() addsimps a_ac@ [Suc_diff_lemma, SUM_ldistr, m_assoc]) 1);
|
7998
|
111 |
qed "poly_assoc_lemma1";
|
|
112 |
|
|
113 |
Goal
|
|
114 |
"!!a::nat=>'a::ring. \
|
|
115 |
\ SUM n (%j. SUM j (%i. a i * b (j-i)) * c (n-j)) = \
|
|
116 |
\ SUM n (%j. a j * SUM (n-j) (%i. b i * c (n-j-i)))";
|
|
117 |
by (rtac (poly_assoc_lemma1 RS mp) 1);
|
|
118 |
by (rtac le_refl 1);
|
|
119 |
qed "poly_assoc_lemma";
|
|
120 |
|
|
121 |
goal Main.thy (* could go to Arith *)
|
|
122 |
"!! n. Suc i <= n ==> Suc (a + (n - Suc i)) = a + (n - i)";
|
|
123 |
by (asm_simp_tac (simpset() delsimps [add_Suc] addsimps [add_Suc_right RS sym, Suc_diff_Suc]) 1);
|
|
124 |
qed "Suc_add_diff_Suc";
|
|
125 |
|
|
126 |
goal Main.thy (* could go to Arith *)
|
|
127 |
"!! n. [| Suc j <= n; i <= j |] ==> \
|
|
128 |
\ n - Suc i - (n - Suc j) = n - i - (n - j)";
|
|
129 |
by (res_inst_tac [("m1", "n - Suc i"), ("n1", "n - Suc j")]
|
|
130 |
(diff_Suc_Suc RS subst) 1);
|
|
131 |
by (subgoal_tac "Suc i <= n" 1);
|
|
132 |
by (asm_simp_tac (simpset() delsimps [diff_Suc_Suc] addsimps [Suc_diff_Suc]) 1);
|
|
133 |
by (fast_arith_tac 1);
|
|
134 |
qed "diff_lemma2";
|
|
135 |
|
|
136 |
Goal
|
|
137 |
"!! a::nat=>'a::ring. j <= n --> \
|
|
138 |
\ SUM j (%i. a i * b (n-i)) = SUM j (%i. a (n-i-(n-j)) * b (i+(n-j)))";
|
8707
|
139 |
by (induct_tac "j" 1);
|
7998
|
140 |
(* Base case *)
|
|
141 |
by (Simp_tac 1);
|
|
142 |
(* Induction step *)
|
|
143 |
by (rtac impI 1);
|
|
144 |
by (etac impE 1);
|
|
145 |
by (rtac Suc_leD 1);
|
|
146 |
by (assume_tac 1);
|
|
147 |
by (stac SUM_Suc2 1);
|
|
148 |
by (stac SUM_Suc 1);
|
|
149 |
by (asm_simp_tac (simpset()
|
|
150 |
addsimps [a_comm, Suc_add_diff_Suc, diff_diff_cancel, diff_lemma2]) 1);
|
|
151 |
qed "poly_comm_lemma1";
|
|
152 |
|
|
153 |
Goal
|
|
154 |
"!!a::nat=>'a::ring. SUM n (%i. a i * b (n-i)) = SUM n (%i. a (n-i) * b i)";
|
|
155 |
by (cut_inst_tac [("j", "n"), ("n", "n")] poly_comm_lemma1 1);
|
|
156 |
by (Asm_full_simp_tac 1);
|
|
157 |
qed "poly_comm_lemma";
|
|
158 |
|
|
159 |
section "Changing the Range of Summation";
|
|
160 |
|
|
161 |
Goal
|
|
162 |
"!! f::(nat=>'a::ring). \
|
|
163 |
\ SUM n (%i. if i = x then f i else <0>) = (if x <= n then f x else <0>)";
|
8707
|
164 |
by (induct_tac "n" 1);
|
7998
|
165 |
(* Base case *)
|
8006
|
166 |
by (Simp_tac 1);
|
7998
|
167 |
(* Induction step *)
|
8006
|
168 |
by (Asm_simp_tac 1);
|
7998
|
169 |
by (Clarify_tac 1);
|
|
170 |
by (res_inst_tac [("f", "f")] arg_cong 1);
|
8006
|
171 |
by (arith_tac 1);
|
7998
|
172 |
qed "SUM_if_singleton";
|
|
173 |
|
|
174 |
Goal
|
|
175 |
"!! f::(nat=>'a::ring). \
|
|
176 |
\ m <= n & (ALL i. m < i & i <= n --> f i = <0>) --> \
|
|
177 |
\ SUM m f = SUM n f";
|
8707
|
178 |
by (induct_tac "n" 1);
|
7998
|
179 |
(* Base case *)
|
|
180 |
by (Simp_tac 1);
|
|
181 |
(* Induction step *)
|
|
182 |
by (case_tac "m <= n" 1);
|
|
183 |
by (rtac impI 1);
|
|
184 |
by (etac impE 1);
|
8707
|
185 |
by (Force_tac 1);
|
7998
|
186 |
by (etac conjE 1);
|
|
187 |
by (dres_inst_tac [("x", "Suc n")] spec 1);
|
8707
|
188 |
by Auto_tac;
|
7998
|
189 |
by (subgoal_tac "m = Suc n" 1);
|
|
190 |
by (Asm_simp_tac 1);
|
|
191 |
by (fast_arith_tac 1);
|
|
192 |
val SUM_shrink_lemma = result();
|
|
193 |
|
|
194 |
Goal
|
|
195 |
"!! f::(nat=>'a::ring). \
|
|
196 |
\ [| m <= n; !!i. [| m < i; i <= n |] ==> f i = <0>; P (SUM n f) |] ==> \
|
|
197 |
\ P (SUM m f)";
|
|
198 |
by (cut_inst_tac [("m", "m"), ("n", "n"), ("f", "f")] SUM_shrink_lemma 1);
|
|
199 |
by (Asm_full_simp_tac 1);
|
|
200 |
qed "SUM_shrink";
|
|
201 |
|
|
202 |
Goal
|
|
203 |
"!! f::(nat=>'a::ring). \
|
|
204 |
\ [| m <= n; !!i. [| m < i; i <= n |] ==> f i = <0>; P (SUM m f) |] ==> \
|
|
205 |
\ P (SUM n f)";
|
|
206 |
by (cut_inst_tac [("m", "m"), ("n", "n"), ("f", "f")] SUM_shrink_lemma 1);
|
|
207 |
by (Asm_full_simp_tac 1);
|
|
208 |
qed "SUM_extend";
|
|
209 |
|
|
210 |
Goal
|
|
211 |
"!! f::(nat=>'a::ring). \
|
|
212 |
\ (ALL i. i < m --> f i = <0>) --> SUM d (%i. f (i+m)) = SUM (m+d) f";
|
8707
|
213 |
by (induct_tac "d" 1);
|
7998
|
214 |
(* Base case *)
|
8707
|
215 |
by (induct_tac "m" 1);
|
7998
|
216 |
by (Simp_tac 1);
|
8707
|
217 |
by (Force_tac 1);
|
7998
|
218 |
(* Induction step *)
|
|
219 |
by (asm_simp_tac (simpset() addsimps add_ac) 1);
|
|
220 |
val SUM_shrink_below_lemma = result();
|
|
221 |
|
|
222 |
Goal
|
|
223 |
"!! f::(nat=>'a::ring). \
|
|
224 |
\ [| m <= n; !!i. i < m ==> f i = <0>; P (SUM (n-m) (%i. f (i+m))) |] ==> \
|
|
225 |
\ P (SUM n f)";
|
8707
|
226 |
by (asm_full_simp_tac
|
|
227 |
(simpset() addsimps [SUM_shrink_below_lemma, add_diff_inverse, leD]) 1);
|
7998
|
228 |
qed "SUM_extend_below";
|
|
229 |
|
|
230 |
section "Result for the Univeral Property of Polynomials";
|
|
231 |
|
|
232 |
Goal
|
|
233 |
"!!f::nat=>'a::ring. j <= n + m --> \
|
|
234 |
\ SUM j (%k. SUM k (%i. f i * g (k - i))) = \
|
|
235 |
\ SUM j (%k. SUM (j - k) (%i. f k * g i))";
|
8707
|
236 |
by (induct_tac "j" 1);
|
7998
|
237 |
(* Base case *)
|
|
238 |
by (Simp_tac 1);
|
|
239 |
(* Induction step *)
|
|
240 |
by (simp_tac (simpset() addsimps [Suc_diff_le]) 1);
|
|
241 |
by (simp_tac (simpset() addsimps [SUM_add]) 1);
|
|
242 |
by (rtac impI 1);
|
|
243 |
by (etac impE 1);
|
|
244 |
by (dtac Suc_leD 1);
|
|
245 |
by (assume_tac 1);
|
|
246 |
by (asm_simp_tac (simpset() addsimps a_ac) 1);
|
|
247 |
val DiagSum_lemma = result();
|
|
248 |
|
|
249 |
Goal
|
|
250 |
"!!f::nat=>'a::ring. \
|
|
251 |
\ SUM (n + m) (%k. SUM k (%i. f i * g (k - i))) = \
|
|
252 |
\ SUM (n + m) (%k. SUM (n + m - k) (%i. f k * g i))";
|
|
253 |
by (rtac (DiagSum_lemma RS mp) 1);
|
|
254 |
by (rtac le_refl 1);
|
|
255 |
qed "DiagSum";
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|