For random variables $X$ and $Y$, let $\mathbb{E}[X]=\mu_X$ and $\mathbb{E}[Y]=\mu_Y$, and define $\widetilde{X}=\left(X-\mu_X\right) / \sigma(X)$ and $\widetilde{Y}=\left(Y-\mu_Y\right) / \sigma(Y)$.
I am wondering why if $\mathbb{E}[(\widetilde{X}-\widetilde{Y})^2]=0$ and Corr$(X,Y)=1$, then "$\widetilde{X} = \widetilde{Y}$ with probability $1$". First of all, I am slightly unsure as to the meaning of this phrase; does it mean that the event of $\widetilde{X} = \widetilde{Y}$ on the probability space over which $X$ and $Y$ are defined has probability $1$? Even if it does mean this, I am at a loss to see how $\widetilde{X} = \widetilde{Y}$ follows from the information given. I would be greatly appreciative of an explanation behind this.
For context, I was reading the following proof, which remarked upon this fact, spurning me to ask this question:
Theorem 16.4. For any pair of random variables $X$ and $Y$ with $\sigma(X)>0$ and $\sigma(Y)>0$, $$ -1 \leq \operatorname{Corr}(X, Y) \leq+1 . $$
Proof. Let $\mathbb{E}[X]=\mu_X$ and $\mathbb{E}[Y]=\mu_Y$, and define $\widetilde{X}=\left(X-\mu_X\right) / \sigma(X)$ and $\widetilde{Y}=\left(Y-\mu_Y\right) / \sigma(Y)$. Then, $\mathbb{E}\left[\widetilde{X}^2\right]=\mathbb{E}\left[\widetilde{Y}^2\right]=1$, so $$ \begin{aligned} & 0 \leq \mathbb{E}\left[(\widetilde{X}-\widetilde{Y})^2\right]=\mathbb{E}\left[\widetilde{X}^2\right]+\mathbb{E}\left[\widetilde{Y}^2\right]-2 \mathbb{E}[\tilde{X} \widetilde{Y}]=2-2 \mathbb{E}[\tilde{X} \widetilde{Y}] \\ & 0 \leq \mathbb{E}\left[(\widetilde{X}+\widetilde{Y})^2\right]=\mathbb{E}\left[\widetilde{X}^2\right]+\mathbb{E}\left[\widetilde{Y}^2\right]+2 \mathbb{E}[\widetilde{X} \widetilde{Y}]=2+2 \mathbb{E}[\widetilde{X} \widetilde{Y}], \end{aligned} $$ which implies $-1 \leq \mathbb{E}[\tilde{X} \widetilde{Y}] \leq+1$. Now, noting that $\mathbb{E}[\tilde{X}]=\mathbb{E}[\tilde{Y}]=0$, we obtain $\operatorname{Corr}(X, Y)=\operatorname{Cov}(\tilde{X}, \tilde{Y})=$ $\mathbb{E}[\widetilde{X} \widetilde{Y}]$. Hence, $-1 \leq \operatorname{Corr}(X, Y) \leq+1$. Note that the above proof shows that $\operatorname{Corr}(X, Y)=+1$ if and only if $\underset{\widetilde{E}}{\mathbb{E}}\left[(\widetilde{X}-\widetilde{Y})^2\right]=0$, which implies $\underset{\widetilde{X}}{\widetilde{Y}}=\tilde{Y}$ with probability 1 . Similarly, $\operatorname{Corr}(X, Y)=-1$ if and only if $\mathbb{E}\left[(\widetilde{X}+\widetilde{Y})^2\right]=0$, which implies $\widetilde{X}=-\widetilde{Y}$ with probability 1 . In terms of the original random variables $X, Y$, this means the following: if $\operatorname{Corr}(X, Y)= \pm 1$, then there exist constants $a$ and $b$ such that, with probability 1 , $$ Y=a X+b $$ where $a>0$ if $\operatorname{Corr}(X, Y)=+1$ and $a<0$ if $\operatorname{Corr}(X, Y)=-1$.