-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.v
38 lines (35 loc) · 829 Bytes
/
Solution.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
Require Import Problem PeanoNat Omega.
Lemma binom_n_Sn (n : nat) : binom n (S n) = 0.
Proof.
remember (S n) as k.
assert (k > n) by omega; clear Heqk.
revert k H.
induction n; simpl; intros.
- destruct k; omega.
- destruct k; [omega|].
rewrite IHn; [|omega].
rewrite IHn; omega.
Qed.
Lemma binom_sum_split (m n : nat) : binom_sum (S m) (S n) = binom_sum m (S n) + binom_sum m n.
Proof.
simpl.
repeat rewrite <- Nat.add_assoc.
apply Nat.add_cancel_l.
induction n.
* destruct m; simpl; auto.
* simpl.
repeat rewrite <- Nat.add_assoc.
rewrite IHn.
omega.
Qed.
Theorem solution: task.
Proof.
unfold task.
induction n; [auto|].
replace (2 ^ S n) with (2 * 2^n) by (simpl; omega).
rewrite <- IHn; clear IHn.
rewrite binom_sum_split.
simpl.
rewrite binom_n_Sn.
auto.
Qed.