  We present a deep embedding of Bellantoni and Cook's syntactic
characterization of polytime functions. We prove formally that it is correct
and complete with respect to the original characterization by Cobham that
required a bound to be proved manually. Compared to the paper proof by
Bellantoni and Cook, we have been careful in making our proof fully contructive
so that we obtain more precise bounding polynomials and more efficient
translations between the two characterizations. Another difference is that we
consider functions on bitstrings instead of functions on positive integers.
This latter change is motivated by the application of our formalization in the
context of formal security proofs in cryptography. Based on our core
formalization, we have started developing a library of polytime functions that
can be reused to build more complex ones.
