Cohomology groups need not determine cohomology ring

Cohomology groups need not determine cohomology ring
It is possible to have two topological spaces $$M_1$$ and $$M_2$$ -- in fact, we can choose both $$M_1$$ and $$M_2$$ to be compact connected orientable manifolds -- such that for every $$n$$, we have an isomorphism of fact about::cohomology groups:

$$H^n(M_1;\mathbb{Z}) \cong H^n(M_2;\mathbb{Z})$$

but the fact about::cohomology ring $$H^*(M_1;\mathbb{Z})$$ is not isomorphic (as a graded ring, or even as a ring) to the cohomology ring $$H^*(M_2;\mathbb{Z})$$. In particular, $$M_1$$ and $$M_2$$ are not homotopy-equivalent spaces and in fact, since our examples are manifolds, they are not even weak homotopy-equivalent spaces.

Homology groups need not determine cohomology ring
Since homology groups determine cohomology groups, an alternative formulation is that it is possible to have two topological spaces $$M_1$$ and $$M_2$$ -- in fact, we can choose both $$M_1$$ and $$M_2$$ to be compact connected orientable manifolds -- such that for every $$n$$, we have an isomorphism of fact about::cohomology groups:

$$H_n(M_1;\mathbb{Z}) \cong H_n(M_2;\mathbb{Z})$$

but the fact about::cohomology ring $$H^*(M_1;\mathbb{Z})$$ is not isomorphic (as a graded ring, or even as a ring) to the cohomology ring $$H^*(M_2;\mathbb{Z})$$.

Related facts

 * Homology groups determine cohomology groups
 * Homology groups and fundamental group need not determine homotopy groups
 * Homotopy groups need not determine homology groups

Proof
We can in fact construct an example of three different compact connected orientable manifolds with the same cohomology groups but different cohomology ring structures. Take $$M_1$$ to be the product of two 2-spheres $$S^2 \times S^2$$, $$M_2$$ to be the connected sum of two complex projective planes with same orientation, and $$M_3$$ to be the connected sum of two complex projective planes with opposite orientation. For all these:

$$H^p(M_1) = H^p(M_2) = H^p(M_3) = \left\lbrace \begin{array}{rl} \mathbb{Z}, & \qquad p = 0,4 \\ \mathbb{Z} \oplus \mathbb{Z}, & \qquad p = 2 \\0 & \qquad \operatorname{otherwise}\end{array}\right.$$

The ring structures we get are:


 * $$H^*(M_1;\mathbb{Z}) \cong \mathbb{Z}[x,y]/(x^2,y^2)$$ where $$x,y$$ generate $$H^2$$ as a free abelian group of rank two and $$xy$$ generates $$H^4$$.
 * $$H^*(M_2;\mathbb{Z}) \cong \mathbb{Z}[x,y]/(x^2 - y^2,x^3,y^3)$$ where $$x,y$$ generate $$H^2$$ as a free abelian group of rank two and $$x^2 = y^2$$ generates $$H^4$$.
 * $$H^*(M_3;\mathbb{Z}) \cong \mathbb{Z}[x,y]/(x^2 + y^2,x^3,y^3)$$ where $$x,y$$ generate $$H^2$$ as a free abelian group of rank two and $$x^2 = -y^2$$ generates $$H^4$$.