-
Notifications
You must be signed in to change notification settings - Fork 14
/
sumkthpowers.v
281 lines (251 loc) · 6.59 KB
/
sumkthpowers.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
(*
MIT License
Copyright (c) 2020 Frédéric Chardard, Institut Camille Jordan /
Université Jean Monnet de Saint-Etienne
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*)
Require Import Reals.
Open Scope R_scope.
Fixpoint bernoullicoeff (n:nat) (k:nat) : R:=
match n with | O => match k with | O => INR 1
| _ => INR 0
end
|(S m)=>
match k with
| O => (sum_f_R0 (fun l => -((bernoullicoeff m l)*(/INR (S l))*(INR n)*/ INR (S (S l)) )) m)
| (S l)=> (bernoullicoeff m l)*/(INR (S l))*(INR n)
end
end.
Definition bernoulli_polynomial (n:nat) (x:R):=
(sum_f_R0 (fun l => (bernoullicoeff n l) *x^l) n).
Theorem bernoulli_polynomial_derivable_pt_lim:
forall n:nat,forall x:R,
derivable_pt_lim (bernoulli_polynomial (S n)) x ((bernoulli_polynomial n x)*(INR (S n))).
intros.
erewrite (_:(_*(INR (S n))=_)).
apply derivable_pt_lim_fs.
apply Nat.lt_0_succ.
Unshelve.
unfold Init.Nat.pred.
rewrite Rmult_comm at 1.
unfold bernoullicoeff.
fold bernoullicoeff.
unfold bernoulli_polynomial.
rewrite scal_sum.
apply sum_eq.
intros.
repeat rewrite<-Rmult_assoc.
field.
apply not_0_INR.
discriminate.
Qed.
Theorem bernoulli_polynomial_derivable_pt_lim_shift:
forall n:nat,forall x:R,
derivable_pt_lim (fun x=> (bernoulli_polynomial (S n) (x+1))) x ((bernoulli_polynomial n (x+1))*(INR (S n))).
unfold derivable_pt_lim.
intros.
destruct (bernoulli_polynomial_derivable_pt_lim n (x+1) eps) as [delta der].
assumption.
exists delta.
intros.
enough(x+h+1=x+1+h) as ->.
apply der;
assumption.
field.
Qed.
Lemma sumzero : forall n:nat, sum_f_R0 (fun _ => 0:R) n=(0:R).
induction n.
simpl sum_f_R0.
reflexivity.
simpl.
rewrite IHn.
apply Rplus_0_r.
Qed.
Theorem bernoulli_polynomial_val_0_1:
forall n:nat,n<>1%nat -> bernoulli_polynomial n 0=bernoulli_polynomial n 1.
intros n nneq1.
unfold bernoulli_polynomial.
transitivity ((bernoullicoeff n 0)+0).
destruct n.
unfold sum_f_R0.
field.
rewrite decomp_sum.
unfold Init.Nat.pred.
rewrite pow_O.
rewrite Rmult_1_r.
f_equal.
rewrite<-(sumzero n) at 1.
apply sum_eq.
intros.
simpl pow.
field.
apply Nat.lt_0_succ.
destruct n.
unfold sum_f_R0,bernoullicoeff.
field.
rewrite decomp_sum.
unfold Init.Nat.pred.
rewrite pow_O.
rewrite Rmult_1_r.
f_equal.
destruct n.
exfalso.
apply nneq1.
reflexivity.
rewrite decomp_sum.
rewrite pow1.
rewrite Rmult_1_r.
simpl Init.Nat.pred.
unfold bernoullicoeff.
fold bernoullicoeff.
unfold bernoullicoeff at 1.
fold bernoullicoeff.
rewrite Rmult_comm.
rewrite<-Rmult_assoc.
rewrite scal_sum.
rewrite Rmult_comm.
rewrite scal_sum.
rewrite<-sum_plus.
rewrite<-(sumzero n) at 1.
apply sum_eq.
intros.
rewrite pow1.
simpl(INR 1).
field.
split;
apply not_0_INR;
discriminate.
apply Nat.neq_0_lt_0.
discriminate.
apply Nat.neq_0_lt_0.
discriminate.
Qed.
Lemma primitive_diff : forall f g fp : (R->R),
(forall x:R, derivable_pt_lim f x (fp x))->
(forall x:R, derivable_pt_lim g x (fp x))->
forall x:R, f x=(plus_fct g (fct_cte ((f 0)-(g 0)))) x.
intros f g fp fder gder.
assert(forall x:R, derivable_pt_lim (f-g) x ((fun _ => 0) x)) as fmpder.
intro x.
rewrite<-(Rminus_diag_eq _ _ (eq_refl (fp x))).
apply derivable_pt_lim_minus.
apply fder.
apply gder.
intro x.
unfold plus_fct,fct_cte.
assert((f-g)%F x=(f-g)%F 0) as diffeq.
destruct (total_order_T x 0) as [xneg|xin];
try destruct xneg as [xin|x0];
try (rewrite x0;
reflexivity);
pose proof (MVT_cor2 (f-g)%F (fun _ => 0) _ _ xin (fun x _ => fmpder x)) as mvt;
destruct mvt as [c mvt];
destruct mvt as [mvt ineq];
rewrite Rmult_0_l in mvt;
pose proof (Rminus_diag_uniq _ _ mvt) as eqfi;
rewrite eqfi;
reflexivity.
unfold minus_fct in diffeq.
rewrite<-diffeq.
field.
Qed.
Lemma primitive_eq:forall f g fp : (R->R),
(forall x:R, derivable_pt_lim f x (fp x))->
(forall x:R, derivable_pt_lim g x (fp x))->
f 0=g 0->
forall x:R, f x=g x.
intros f g fp fder gder init x.
transitivity ((plus_fct g (fct_cte ((f 0)-(g 0)))) x).
rewrite (primitive_diff f g fp);
try assumption;
try reflexivity.
unfold plus_fct,fct_cte.
rewrite init.
field.
Qed.
Lemma kthpowers : forall n:nat, forall x:R,
x^n*(INR (S n))=(bernoulli_polynomial (S n) (x+1))-(bernoulli_polynomial (S n) x).
induction n.
intro.
unfold bernoulli_polynomial,sum_f_R0,bernoullicoeff.
unfold sum_f_R0,INR,pow.
field.
apply (primitive_eq _ _ (fun x=>(INR (S n))*x^n*(INR (S (S n)))) ).
intro x.
apply (derivable_pt_lim_scal_right (fun x=>x^(S n)) x _ (INR (S (S n)))).
pose proof (derivable_pt_lim_pow x (S n)) as derpow.
unfold Init.Nat.pred in derpow.
apply derpow.
intro x.
erewrite(_:(INR (S n) * x ^ n * INR (S (S n)))=_).
apply derivable_pt_lim_minus.
apply bernoulli_polynomial_derivable_pt_lim_shift.
apply bernoulli_polynomial_derivable_pt_lim.
unfold pow.
repeat rewrite Rmult_0_l.
rewrite bernoulli_polynomial_val_0_1.
rewrite Rplus_0_l.
rewrite Rminus_diag_eq;
reflexivity.
discriminate.
Unshelve.
rewrite(Rmult_comm (INR (S n))).
rewrite IHn.
field.
Qed.
Lemma sum_kthpowers : forall r:nat, forall n:nat,
(0<r)%nat->
sum_f_R0 (fun k => ((INR k)^r)%R) n
=((bernoulli_polynomial (S r) (INR n+1))-(bernoulli_polynomial (S r) 0))/(INR r+1).
intros r n rneq0.
induction n.
unfold INR.
fold INR.
rewrite bernoulli_polynomial_val_0_1.
rewrite Rplus_0_l.
unfold sum_f_R0.
unfold pow,INR.
fold INR.
fold pow.
induction r.
exfalso.
apply (Nat.neq_0_lt_0 0).
assumption.
reflexivity.
unfold pow.
fold pow.
field.
rewrite<-S_INR.
apply not_0_INR.
discriminate.
apply not_eq_S.
intro.
apply Nat.neq_0_lt_0 in rneq0.
contradiction.
unfold sum_f_R0.
fold sum_f_R0.
rewrite IHn.
enough(INR (S n) ^ r=(INR (S n) ^r * (INR (S r)))/(INR (S r))) as ->.
rewrite kthpowers.
repeat rewrite<-S_INR.
field.
apply not_0_INR.
discriminate.
field.
apply not_0_INR.
discriminate.
Qed.