Theorems of the alternative and optimality conditions