Generalization of Bell's theorem