Determining whether there exists a length-$k$ proof of a statement is a problem in the complexity class $NP$. So if there is a constructive proof that $P=NP$, that would also provide a polynomial time algorithm for proving theorems.
First you would try to find a proof of length $1$ in polynomial time, then try to find a proof of length $2$ in polynomial time, then length $3$, and so forth. If there is a finite proof then you will find it in polynomial time.
In case the statement is false, one should also be using the algorithm to try to prove the statement false simultaneously.
A few issues with this are
- Most mathematicians think $P \neq NP$,
- A future proof that $P=NP$ might be indirect based on contradiction, and not provide an actual algorithm,
- Even polynomial time algorithms can be prohibitively expensive - eg., an algorithm with running time $O(k^{100000})$ would be "polynomial time", but still completely intractible from a practical persective.
- There is an implicit dependence on the length of the shortest proof, which though fixed for any particular theorem, is still unbounded for theorems in general.
- In the extreme, if you try to prove a statement (or it's negation) that is undecidable your algorithm will keep running forever,
- Even if algorithms can prove or disprove statements, that still doesn't help in deciding what statements are "interesting". Humans will be needed to decide what statements to run the algorithm on.