1. A method for defining declarative code according to a declarative programming model comprising a type system supporting type refinement and type membership, including: receiving a specification of at least one programming construct of a declarative programming language including receiving a specification of a type refinement construct that defines at least one type by specifying values for which a Boolean expression is true, and receiving, within a first expression of the type refinement construct, a specification of a type membership test construct that determines whether one or more resulting values of evaluating a second expression that is included in the first expression is a member of an indicated type; and generating a machine readable representation of code based on the specification of the at least one programming construct, one or more judgments associated with the type membership test being associated with the first expression, the one or more judgments being based on at least one context associated with at least one type.