Generalizing Boolean Satisfiability II: Theory