-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnicomachus.v
More file actions
25 lines (22 loc) · 1.07 KB
/
nicomachus.v
File metadata and controls
25 lines (22 loc) · 1.07 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
From mathcomp Require Import all_boot.
(******************************************************************************)
(* *)
(* Nicomachus theorem *)
(* *)
(******************************************************************************)
Lemma sum_gauss n : (\sum_(i < n) i).*2 = n * n.-1.
Proof.
elim: n => [|n IH /=]; first by rewrite big_ord0.
rewrite big_ord_recr /= doubleD IH /= -muln2 -mulnDr addn2 [RHS]mulnC.
by case: (n).
Qed.
Lemma nicomachus n : \sum_(i < n) i ^ 3 = (\sum_(i < n) i) ^ 2.
Proof.
do 2 apply: double_inj.
rewrite -2![in RHS]muln2 -mulnAC -mulnA !muln2 !sum_gauss mulnn.
elim: n => [|n IH /=]; first by rewrite !big_ord0.
rewrite big_ord_recr /= !doubleD IH !expnMn.
rewrite [n ^ 3]expnS [n * _]mulnC -!muln2 -2!mulnA -mulnDr mulnC !muln2.
case: (n) => [//|n1 /=]; congr (_ * _).
by rewrite -[in RHS]addn2 sqrnD mulSn addnA -doubleMr !(muln2, mul2n).
Qed.