Last active
March 15, 2020 21:59
-
-
Save pedrominicz/92269ea64ee503064cf7c5240beea74c to your computer and use it in GitHub Desktop.
Software Foundations: Functional Programming 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
Inductive bin : Type := | |
| bz | |
| b0 (b : bin) | |
| b1 (b : bin). | |
Fixpoint increment (b : bin) : bin := | |
match b with | |
| bz => b1 bz | |
| b0 b => b1 b | |
| b1 b => b0 (increment b) | |
end. | |
Fixpoint bin_to_nat (b : bin) : nat := | |
match b with | |
| bz => O | |
| b0 b => 2 * bin_to_nat b | |
| b1 b => 1 + 2 * bin_to_nat b | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment