Created
April 24, 2014 15:08
-
-
Save puffnfresh/11258181 to your computer and use it in GitHub Desktop.
Verified monoid in Coq.
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
Inductive bool : Type := | |
| true : bool | |
| false : bool. | |
Class Monoid (A : Type) := | |
{ | |
empty : A ; | |
append : A -> A -> A ; | |
left_neutrality : forall x, append empty x = x ; | |
right_neutrality : forall x, append x empty = x ; | |
associativity : forall x y z, append x (append y z) = append (append x y) z | |
}. | |
Program | |
Instance bool_Monoid : Monoid bool := | |
{ | |
empty := false ; | |
append a b := match a with | |
| true => true | |
| false => b | |
end | |
}. | |
Next Obligation. | |
intros. | |
reflexivity. | |
Qed. | |
Next Obligation. | |
intros. | |
destruct x. | |
reflexivity. | |
reflexivity. | |
Qed. | |
Next Obligation. | |
intros. | |
destruct x. | |
reflexivity. | |
destruct y. | |
reflexivity. | |
reflexivity. | |
Qed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment