I am working through the book "Software Foundations", and am on the last problem in Chapter two. The problem asks to convert a natural number into a binary number, where a binary number is defined in the following ways:
- [is] zero,
- [is] twice a binary number, or
- [is] one more than twice a binary number.
My thought process is that if a natural number is even, then it can be expressed as
double(nat_to_bin n)
However, in my Fixpoint definition, when I tried to write
(evenb n' = true) => double(nat_to_bin)
I got an error because evenb n' is not a constructor of nat. Is there any way for me to create a conditional such that the above line would be a valid function definition, without changing the definition of nat?