I want to prove that a local ring $A$ is Cohen-Macaulay if and only if for every $A$-module $M$ we have $\mathrm{grade}\;M+\mathrm{dim}\;M=\mathrm{dim}\;A$.
If that equation holds we just take $M=k$ (the residue field) and we obtain $A$ is Cohen-Macaulay.
Now suppose that $A$ is CM. In general we have
$\mathrm{grade}\;M=\mathrm{inf}_{p\in\mathrm{Supp}\;M}\;\mathrm{ht}\;p$
$\mathrm{dim}\;M=\mathrm{sup}_{p\in\mathrm{Supp}\;M}\;\mathrm{dim}\;A/p$
Now the notes where I am studying conclude saying that the wanted equality follows from the fact that the spectrum of a Cohen-Macaulay ring is bi-dimensional (that I don't know what it means).
It seems to me that I have to use the property that in a CM ring $\mathrm{ht}\;I+\mathrm{dim}\;A/I=\mathrm{dim}\;A$, and apply the two formulas above, but the fact that is bothering me is that in one of them there is a sup and in the other an inf, so I really don't know how to conclude. Any help?