Re-calling/re-printing a theorem from an external document [duplicate]

For a manuscript I need to include theorem proofs as supplementary material. So I mention the theorem in the main file and I need to re-print the theorem in the supplementary material with the same theorem number and then provide the proof.

For this purpose I define the theorem in the main.tex file as follows:

\begin{restatable}{thm}{firsttheorem}
\label{thm:first}
Sample theorem.
\end{restatable}

\begin{proof}
Refer to supplementary material.
\end{proof}


Then in my supplementary material file supp.tex I use the xr package and refer to my main document as

\usepackage{xr}
\externaldocument{../main}


But I am not able to refer to the theorem as such

\firsttheorem*


It gives the following error message

Undefined control sequence.
\myfirsttheorem