Naive version of encode

This is a naive version of encoding (one that one would write in
Haskell, say). It fails the totality checker.
Make encode provably total
Naive version of decode
A proof that decode works
Require totality
An alternative way of proving that decodeWorks

This time we not only return the result in encode, but also a proof that
when decode is called on it, it returns the correct result.