I know how to prove that Spearman's $ \rho / r_s$ can be written as $r_s = 1-\frac{6\sum\limits_{i=1}^nd_i^2}{n(n^2-1)}$ with $d_i=R(x_i)-R(y_i)$ when there are no ties.
Now I came across the formula for tied ranks: $r_s = 1-\frac{6\left(\sum\limits_{i=1}^nd_i^2+\sum\limits_{j=1}^n\frac{t_j^3-t_j}{12}\right)}{n(n^2-1)}$ where $t_j$ represents the $j^{th}$ tie length. (I found this formula at the following link: https://www.onlinemath4all.com/spearman-rank-correlation-coefficient.html )
Another version of this formula would be $r_s = \frac{\frac{n^3-n}{6}-\sum d_i^2 - \sum T_x -\sum T_y}{\sqrt{(\frac{n^3-n}{6}-2\sum T_x)(\frac{n^3-n}{6}-2\sum T_y)}}$ with $\sum T_x = \frac{\sum t_i^3-t_i}{12}$ and $\sum T_y = \frac{\sum t_i^3-t_i}{12}$ where $t_i$ is the number of groups the random variables $X$ and $Y$ tie respectively. (I found this formula at the following link: http://webspace.ship.edu/pgmarr/Geo441/Lectures/Lec%2011%20-%20Spearman%27s%20and%20Cramer%27s%20Correlation.pdf )
I'm unable to prove either of both formulas for tied ranks. I tried to rewrite $R(x_i)$ in a different way but always failed to obtain the formula. My question therefore is if anyone has a hint on how to prove any of the two formulas or maybe if someone has a complete proof?
Thank you very much in advance for any help.