Formulation of N- and v-representable density functional theory