Created
May 22, 2017 11:44
-
-
Save MikeMKH/ec0f7cf09924a8c95438e75b7630a15e to your computer and use it in GitHub Desktop.
Addition properties in Coq
This file contains hidden or 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
Lemma zero_addition_identity_right : | |
forall x : nat, x + 0 = x. | |
Proof. | |
intro x; induction x. | |
- compute; reflexivity. | |
- simpl; f_equal; apply IHx. | |
Qed. | |
Lemma zero_addition_identity_left : | |
forall x : nat, x = x + 0. | |
Proof. | |
intro x; induction x. | |
- simpl; reflexivity. | |
- simpl; f_equal; apply IHx. | |
Qed. | |
Lemma addition_distributive_S : | |
forall n m : nat, S (m + n) = m + S n. | |
Proof. | |
intros n m; induction m; simpl. | |
- reflexivity. | |
- rewrite IHm; reflexivity. | |
Qed. | |
Theorem addition_associative : | |
forall a b c : nat, (a + b) + c = a + (b + c). | |
Proof. | |
intros a b c; induction a; simpl. | |
- reflexivity. | |
- f_equal; apply IHa. | |
Qed. | |
Theorem addition_commutative : | |
forall a b : nat, a + b = b + a. | |
Proof. | |
intros a b; induction a; simpl. | |
- apply zero_addition_identity_left. | |
- rewrite IHa; apply addition_distributive_S. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment