-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangular.v
More file actions
170 lines (142 loc) · 3.71 KB
/
Triangular.v
File metadata and controls
170 lines (142 loc) · 3.71 KB
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
(*
(C) Copyright 2010, COQTAIL team
Project Info: http://sourceforge.net/projects/coqtail/
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*)
Require Import Reals.
Require Import Rseries_RiemannInt.
Require Import Rseries_facts.
Require Import Rtactic.
Require Import Rsequence_facts.
Require Import Lra.
Definition triangle n := INR (n * S n) / 2.
Lemma triangle_sum n : sum_f_R0 INR n = triangle n.
Proof.
unfold triangle.
induction n.
simpl; field.
rewrite tech5.
rewrite IHn.
elim_ident.
field.
Qed.
Lemma triangle_non_negative n : 0 <= triangle n.
Proof.
intros.
unfold triangle.
INR_solve.
Qed.
Lemma triangle_positive n : 0 < triangle (S n).
Proof.
intros.
unfold triangle.
INR_solve.
Qed.
Lemma sum_consecutive_triangle n : triangle (S n) + triangle n = INR (S n) * INR (S n).
Proof.
intros.
unfold triangle.
elim_ident.
field.
Qed.
Lemma difference_consecutive_triangle n : (triangle (S n) - triangle n)² = INR (S n) * INR (S n).
Proof.
intros.
unfold "²", triangle.
elim_ident.
field.
Qed.
Lemma sum_triangular_tetrahedral n : sum_f_R0 triangle n = INR (n * S n * S (S n)) / 6.
Proof.
unfold triangle.
induction n.
simpl.
field.
rewrite tech5, IHn.
elim_ident.
field.
Qed.
Definition inv_snssn n := / INR (S n * S (S n)).
Definition inv_sn n := / INR (S n).
Lemma diff_inv_snssn n : inv_snssn n = inv_sn n - inv_sn (S n).
Proof.
intros.
unfold inv_sn, inv_snssn.
elim_ident.
field.
INR_solve.
Qed.
Lemma sum_inv_snssn n : sum_f_R0 inv_snssn n = 1 - inv_sn (S n).
Proof.
induction n.
compute; field.
simpl.
rewrite IHn.
rewrite diff_inv_snssn.
ring.
Qed.
Lemma inv_sn_cv_0 : Rseq_cv inv_sn 0.
Proof.
intros e epos.
assert (upepos : (0 < up (/ e))%Z).
apply lt_IZR.
eapply Rlt_trans.
2:apply (archimed (/e)).
auto with *.
assert (upenneg : (0 <= up (/ e))%Z) by auto with *.
destruct (IZN _ upenneg) as (N, HN).
exists N.
intros n Hn.
unfold R_dist, inv_sn.
rewrite Rminus_0_r.
rewrite Rabs_Rinv_pos; [ | INR_solve ].
rewrite <- (Rinv_inv e); auto with *.
apply Rinv_lt_contravar.
apply Rmult_lt_0_compat; auto with *.
eapply Rle_lt_trans with (INR n); [ | INR_solve ].
eapply Rle_trans with (IZR (up (/ e))).
left.
apply (archimed (/ e)).
rewrite HN.
rewrite <- INR_IZR_INZ.
INR_solve.
Qed.
Lemma ser_cv_inv_snssn : Rser_cv inv_snssn 1.
Proof.
replace 1 with (1 - 0) by ring.
eapply Rseq_cv_eq_compat.
2:apply (Rseq_cv_minus_compat (fun _ => 1) (Rseq_shift inv_sn)).
intro n.
unfold Rseq_minus.
unfold Rseq_shift.
apply sum_inv_snssn.
apply Rseq_constant_cv.
apply Rseq_cv_shift_compat_reciprocal.
apply inv_sn_cv_0.
Qed.
Lemma sum_reciprocal_triangular : Rser_cv (fun n => / triangle (S n)) 2.
Proof.
replace 2 with (2 * 1) by (compute; field).
apply Rseq_cv_eq_compat with (Rseq_mult (Rseq_constant 2) (sum_f_R0 inv_snssn)).
intro n.
unfold Rseq_mult, Rseq_inv, Rseq_constant, inv_snssn, triangle.
rewrite scal_sum.
apply Rseq_sum_ext; intro.
elim_ident.
field.
INR_solve.
apply Rseq_cv_mult_compat.
auto with *.
apply ser_cv_inv_snssn.
Qed.