1. A method for validating at least a portion of a declarative program based on a background theory for a programming language having a type system that supports type test and refinement, including: for a given environment, translating, by a computing device, a programming construct of the declarative program to at least one first order logic formula construct based on a semantic analysis; determining, by the computing device, a validity of the at least one first order logic formula construct based on an analysis of the at least one first order logic formula construct; and determining, by the computing device, whether a first type of the programming construct is a valid subtype of a second type of the programming construct based on the validity determination, including: forming, for each type T, a formula F[T](x) that is true if and only if x is a value of type T; and checking whether a type S is a subtype of the type T through use of a formula of the form (∀x. F[S](x)= F[T](x)).