To prove that X equals Y almost surely given the conditions \mathbb{E}(X|Y)=Y and \mathbb{E}(Y|X)=X, one must utilize the properties of conditional expectation. The definition of \mathbb{E}(X|Y) is the expected value of X given the information contained in Y. By applying the law of total expectation and the properties of conditional expectations, it can be shown that the equality implies that the random variables X and Y must be equal almost surely. This conclusion stems from the fact that if both expectations equal their respective variables, the only solution is X=Y. Thus, the proof hinges on the definitions and properties of conditional expectations.