A general theory of algebras with quantifiers