1. Given a formal specification, find a program that meets the specification.
2. The apparently simpler problem of checking whether a given program meets a specification.
Both are undecidable. That said, there is an extensive literature on practical approaches to this problem. They generally suffer from intractability.
http://cfpm.org/pub/papers/tiofdm.pdf
I suggest looking at Robert Harper's book on type theory instead.