Formal construction and verification of programs in Type Theory