Created
January 4, 2020 18:42
-
-
Save geo2a/31381aeb345c789761504da1b5d42168 to your computer and use it in GitHub Desktop.
Equational Reasoning in Coq using Tactic Notations
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
Tactic Notation | |
"`Begin " constr(lhs) := idtac. | |
Tactic Notation | |
"≡⟨ " tactic(proof) "⟩" constr(lhs) := | |
(stepl lhs by proof). | |
Tactic Notation | |
"≡⟨ " tactic(proof) "⟩" constr(lhs) "`End" := | |
(now stepl lhs by proof). | |
Require Import Coq.Init.Peano. | |
Theorem plus_comm : | |
forall (m n : nat), m + n = n + m. | |
Proof. | |
intros m n. | |
induction n. | |
- `Begin | |
(m + 0). | |
≡⟨ now rewrite <- plus_n_O ⟩ | |
(m). | |
≡⟨ reflexivity ⟩ | |
(0 + m) | |
`End. | |
- `Begin | |
(m + S n). | |
≡⟨ now rewrite plus_n_Sm ⟩ | |
(S (m + n)). | |
≡⟨ now rewrite IHn ⟩ | |
(S (n + m)). | |
≡⟨ reflexivity ⟩ | |
(S n + m) | |
`End. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment