Created
February 25, 2018 13:51
-
-
Save mizunashi-mana/8a1257f81a7d783fb8e18535b738b304 to your computer and use it in GitHub Desktop.
なんかできた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Require Import Arith. | |
Fixpoint sum (n: nat) {struct n}: nat := | |
match n with | |
| O => O | |
| S p => S p + sum p | |
end. | |
Lemma sum_Sn: forall n, sum (S n) = S n + sum n. | |
Proof. | |
simpl; reflexivity. | |
Qed. | |
Lemma succ_add: forall n, S n = n + 1. | |
Proof. | |
Admitted. | |
Lemma add_diag: forall n, n + n = 2 * n. | |
Proof. | |
Admitted. | |
Goal forall (n: nat) (m: nat), m = 2 * sum n -> m = n * (n + 1). | |
Proof. | |
induction n. | |
intros; apply H. | |
rewrite sum_Sn. | |
intros. | |
rewrite Nat.mul_add_distr_l. | |
rewrite Nat.mul_succ_l. | |
rewrite Nat.mul_1_r. | |
rewrite <- Nat.add_assoc. | |
rewrite add_diag. | |
rewrite Nat.add_comm. | |
rewrite Nat.mul_add_distr_l in H. | |
rewrite (IHn (2 * sum n)) in H. | |
rewrite <- succ_add in H. | |
apply H. | |
reflexivity. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment