1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: Rprod.v 10146 2007-09-27 12:28:12Z herbelin $ i*)
11
Require Import Compare.
13
Require Import Rfunctions.
14
Require Import Rseries.
15
Require Import PartSum.
16
Require Import Binomial.
17
Open Local Scope R_scope.
20
Boxed Fixpoint prod_f_R0 (f:nat -> R) (N:nat) {struct N} : R :=
23
| S p => prod_f_R0 f p * f (S p)
26
Notation prod_f_SO := (fun An N => prod_f_R0 (fun n => An (S n)) N).
30
forall (An:nat -> R) (n k:nat),
33
prod_f_R0 An k * prod_f_R0 (fun l:nat => An (k +1+l)%nat) (n - k -1).
35
intros; induction n as [| n Hrecn].
36
absurd (k < 0)%nat; omega.
37
cut (k = n \/ (k < n)%nat);[intro; elim H0; intro|omega].
38
replace (S n - k - 1)%nat with O; [rewrite H1; simpl|omega].
39
replace (n+1+0)%nat with (S n); ring.
40
replace (S n - k-1)%nat with (S (n - k-1));[idtac|omega].
41
simpl in |- *; replace (k + S (n - k))%nat with (S n).
42
replace (k + 1 + S (n - k - 1))%nat with (S n).
43
rewrite Hrecn; [ ring | assumption ].
50
forall (An:nat -> R) (N:nat),
51
(forall n:nat, (n <= N)%nat -> 0 <= An n) -> 0 <= prod_f_R0 An N.
53
intros; induction N as [| N HrecN].
54
simpl in |- *; apply H; trivial.
55
simpl in |- *; apply Rmult_le_pos.
56
apply HrecN; intros; apply H; apply le_trans with N;
57
[ assumption | apply le_n_Sn ].
63
forall (An Bn:nat -> R) (N:nat),
64
(forall n:nat, (n <= N)%nat -> 0 <= An n <= Bn n) ->
65
prod_f_R0 An N <= prod_f_R0 Bn N.
67
intros; induction N as [| N HrecN].
68
elim H with O; trivial.
69
simpl in |- *; apply Rle_trans with (prod_f_R0 An N * Bn (S N)).
70
apply Rmult_le_compat_l.
71
apply prod_SO_pos; intros; elim (H n (le_trans _ _ _ H0 (le_n_Sn N))); intros;
73
elim (H (S N) (le_n (S N))); intros; assumption.
74
do 2 rewrite <- (Rmult_comm (Bn (S N))); apply Rmult_le_compat_l.
75
elim (H (S N) (le_n (S N))); intros.
76
apply Rle_trans with (An (S N)); assumption.
77
apply HrecN; intros; elim (H n (le_trans _ _ _ H0 (le_n_Sn N))); intros;
81
(** Application to factorial *)
83
forall n:nat, INR (fact n) = prod_f_R0 (fun k:nat =>
84
(match (eq_nat_dec k 0) with
89
intro; induction n as [| n Hrecn].
91
simpl; rewrite <- Hrecn.
92
case n; auto with real.
93
intros; repeat rewrite plus_INR;rewrite mult_INR;ring.
96
Lemma le_n_2n : forall n:nat, (n <= 2 * n)%nat.
99
replace (2 * 0)%nat with 0%nat; [ apply le_n | ring ].
100
intros; replace (2 * S n0)%nat with (S (S (2 * n0))).
101
apply le_n_S; apply le_S; assumption.
102
replace (S (S (2 * n0))) with (2 * n0 + 2)%nat; [ idtac | ring ].
103
replace (S n0) with (n0 + 1)%nat; [ idtac | ring ].
107
(** We prove that (N!)^2<=(2N-k)!*k! forall k in [|O;2N|] *)
108
Lemma RfactN_fact2N_factk :
111
Rsqr (INR (fact N)) <= INR (fact (2 * N - k)) * INR (fact k).
113
assert (forall (n:nat), 0 <= (if eq_nat_dec n 0 then 1 else INR n)).
114
intros; case (eq_nat_dec n 0); auto with real.
115
assert (forall (n:nat), (0 < n)%nat ->
116
(if eq_nat_dec n 0 then 1 else INR n) = INR n).
117
intros n; case (eq_nat_dec n 0); auto with real.
118
intros; absurd (0 < n)%nat; omega.
119
intros; unfold Rsqr in |- *; repeat rewrite fact_prodSO.
120
cut ((k=N)%nat \/ (k < N)%nat \/ (N < k)%nat).
121
intro H2; elim H2; intro H3.
122
rewrite H3; replace (2*N-N)%nat with N;[right; ring|omega].
123
case H3; intro; clear H2 H3.
124
rewrite (prod_SO_split (fun l:nat => if eq_nat_dec l 0 then 1 else INR l) (2 * N - k) N).
125
rewrite Rmult_assoc; apply Rmult_le_compat_l.
126
apply prod_SO_pos; intros; auto.
127
replace (2 * N - k - N-1)%nat with (N - k-1)%nat.
128
rewrite Rmult_comm; rewrite (prod_SO_split
129
(fun l:nat => if eq_nat_dec l 0 then 1 else INR l) N k).
130
apply Rmult_le_compat_l.
131
apply prod_SO_pos; intros; auto.
132
apply prod_SO_Rle; intros; split; auto.
141
rewrite <- (Rmult_comm (prod_f_R0 (fun l:nat =>
142
if eq_nat_dec l 0 then 1 else INR l) k));
143
rewrite (prod_SO_split (fun l:nat =>
144
if eq_nat_dec l 0 then 1 else INR l) k N).
145
rewrite Rmult_assoc; apply Rmult_le_compat_l.
146
apply prod_SO_pos; intros; auto.
148
rewrite (prod_SO_split (fun l:nat =>
149
if eq_nat_dec l 0 then 1 else INR l) N (2 * N - k)).
150
apply Rmult_le_compat_l.
151
apply prod_SO_pos; intros; auto.
152
replace (N - (2 * N - k)-1)%nat with (k - N-1)%nat.
153
apply prod_SO_Rle; intros; split; auto.
167
Lemma INR_fact_lt_0 : forall n:nat, 0 < INR (fact n).
169
intro; apply lt_INR_0; apply neq_O_lt; red in |- *; intro;
170
elim (fact_neq_0 n); symmetry in |- *; assumption.
173
(** We have the following inequality : (C 2N k) <= (C 2N N) forall k in [|O;2N|] *)
174
Lemma C_maj : forall N k:nat, (k <= 2 * N)%nat -> C (2 * N) k <= C (2 * N) N.
176
intros; unfold C in |- *; unfold Rdiv in |- *; apply Rmult_le_compat_l.
178
replace (2 * N - N)%nat with N.
179
apply Rmult_le_reg_l with (INR (fact N) * INR (fact N)).
180
apply Rmult_lt_0_compat; apply INR_fact_lt_0.
181
rewrite <- Rinv_r_sym.
183
apply Rmult_le_reg_l with (INR (fact k) * INR (fact (2 * N - k))).
184
apply Rmult_lt_0_compat; apply INR_fact_lt_0.
185
rewrite Rmult_1_r; rewrite <- mult_INR; rewrite <- Rmult_assoc;
186
rewrite <- Rinv_r_sym.
187
rewrite Rmult_1_l; rewrite mult_INR; rewrite (Rmult_comm (INR (fact k)));
188
replace (INR (fact N) * INR (fact N)) with (Rsqr (INR (fact N))).
189
apply RfactN_fact2N_factk.
192
rewrite mult_INR; apply prod_neq_R0; apply INR_fact_neq_0.
193
apply prod_neq_R0; apply INR_fact_neq_0.