Inverse formulas of rotations using the substitution method 
Given the direct rotations
$$
\mathcal R \begin{cases}
x=X\cos\vartheta-Y\sin\vartheta\equiv x'\cos\vartheta-y'\sin\vartheta\\
y=X\sin\vartheta+Y\cos\vartheta\equiv x'\sin\vartheta+y'\cos\vartheta
\end{cases} \tag 1 $$
to find the inverse rotations,
$$\mathcal{R}^{-1}\begin{cases} x'\equiv X=x \cos\vartheta+y \sin\vartheta \\ y'\equiv Y=-x \sin\vartheta+y \cos\vartheta \end{cases} \tag 2$$
I can use Cramer's rule,
$$x'=X=\frac{ \left|\begin{matrix}
x & -\sin(\vartheta) \\
y & \cos(\vartheta)
\end{matrix}\right|}{\cos^2\vartheta+\sin^2\vartheta\equiv 1}=x \cos \vartheta +y\sin \vartheta$$
Same for $Y$, I will have:
$$y'=Y=-x \sin\vartheta+y \cos\vartheta$$
But with the substitution method to find the $(2)$ quickly, starting from the $(1)$, as with the Cramer's method (or thinking that $\cos(-\vartheta)=\cos\vartheta$ and $\sin(-\vartheta)=-\sin\vartheta$), I think that is more complicated. I have done some steps (see below),
$$
\begin{cases}
x=X\cos\vartheta-Y\sin\vartheta\\
y=X\sin\vartheta+Y\cos\vartheta
\end{cases}$$
If  $\cos\vartheta\neq 0$
$$
\begin{cases}
X=\frac{x+Y\sin\vartheta}{\cos\theta}\\
Y\cos\vartheta=y-\left(\frac{x+Y\sin\vartheta}{\cos\theta}\right)\sin\vartheta
\end{cases}$$
$$
\begin{cases}
X=\frac{x+Y\sin\vartheta}{\cos\theta}\\
Y\cos\vartheta=y-\frac{x\sin\vartheta+Y\sin^2\vartheta}{\cos\theta}
\end{cases}$$
$$
\begin{cases}
X=\frac{x+Y\sin\vartheta}{\cos\theta}\\
Y=\frac{y}{\cos\vartheta}-\frac{x\sin\vartheta+Y\sin^2\vartheta}{\cos^2\vartheta}
\end{cases}$$
but, after, I have leaved all. Every solution for this method is welcome.

Let $c=\cos\vartheta$ and $s=\sin\vartheta$. So, your system is$$\left\{\begin{array}{l}x=cX-sY\\y=sX+cY\end{array}\right.$$and we have\begin{align}\left\{\begin{array}{l}x=cX-sY\\y=sX+cY\end{array}\right.&\iff\left\{\begin{array}{l}X=\frac1c(x+sY)\\y=\frac sc(x+sY)+cY=\frac scx+\left(\frac{s^2}c+c\right)Y=\frac scx+\frac1cY\end{array}\right.\\&\iff\left\{\begin{array}{l}X=\frac1c(x+sY)\\Y=-sx+cy\end{array}\right.\\&\iff\left\{\begin{array}{l}X=\frac1c\bigl(x+s(-sx+cy)\bigr)=cx+sy\\Y=-sx+cy.\end{array}\right.\end{align}
