A problem in probability theory I was trying to solve a problem and I got stuck at the penultimate step (I think).
I could show that Var(X) = Var(Y) = Cov(X,Y), where X and Y are random variables with finite means and variances.
Based on above statement, can I say that X and Y are the same? or P(X=Y) = 1?
 A: You will need the following simple result.
Lemma. If $\mathrm{Var}[Z]=0$, then $Z=\mathrm{E}[Z]$, almost surely.
Proof (check cardinal's comment for a contrapositive argument). It is easy to check that
$$
  \left\{ Z = \mathrm{E}[Z] \right\} = \bigcap_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| < \frac{1}{n} \right\} \, .
$$
By Tchebyshev's inequality, we have
$$
  P \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} \leq n^2 \mathrm{Var}[Z] = 0 \, ,
$$
for every $n\geq 1$. Hence, using De Morgan's identity and the subadditivity of $P$, we have
$$
  P\left\{ Z = \mathrm{E}[Z] \right\} = 1 - P\left(\bigcup_{n\geq 1} \left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\}\right) \geq 1 - \sum_{n\geq 1} P\left\{ |Z - \mathrm{E}[Z]| \geq \frac{1}{n} \right\} = 1 \, ,
$$
as desired.
Using the hints given by cardinal and whuber, you have what you need.
Proposition. If $X$ and $Y$ are integrable random variables such that $$\mathrm{Var}[X] = \mathrm{Var}[Y]=\mathrm{Cov}[X,Y] \, ,$$ then $X=Y+c$, almost surely, where the constant $c=\mathrm{E}[X]-\mathrm{E}[Y]$.
Proof. Defining $Z=X-Y$, the formula for the variance of the difference of two random variables gives
$$
\mathrm{Var}[Z]=\mathrm{Var}[X]+\mathrm{Var}[Y]-2\,\mathrm{Cov}[X,Y] = 2\,\mathrm{Cov}[X,Y] -2\,\mathrm{Cov}[X,Y] = 0 \, .
$$
The Lemma yields the desired result, since $\mathrm{E}[Z]=\mathrm{E}[X-Y]=\mathrm{E}[X]-\mathrm{E}[Y]$.
