A Formal Theory of Generalized Intermediate Syllogisms