As suggested by Barbara Beeton here, I am posting this as a new question.
When a proof ends in a displayed formula, to have the QED symbol in the correct place you have to use \qedhere inside the formula.
The problem is that if the formula is given by means of the alignat* environment, then LaTeX issues a (harmless) warning when compiling.
Here is a MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\begin{document}
\begin{proof}
\begin{alignat*}{2}
&x && =1 \\
&y && =2
\qedhere
\end{alignat*}
\end{proof}
\begin{proof}
\begin{align*}
x & =1 \\
y & =2
\qedhere
\end{align*}
\end{document}
Please note that amsmath is called before amsthm, as specified in amsthdoc
When compiling, I get the (double) warning
Package amsthm Warning: The \qedhere command may not work correctly here on input line 10.
Package amsthm Warning: The \qedhere command may not work correctly here on input line 10.
The QED symbol is still there (albeit not flushed to the right).
If you use the environment align* instead of alignat*, on the other hand, everything works flawlessly.
As Barbara said, they should work the same, but it looks like they don't.
P.S.: A way to avoid the warning is to use \tag*{\qedhere} instead of \qedhere, which has also the side effect to flush the QED symbol to the right, restoring it to its intended position, but this looks more like a sort of workaround than the intended use of \qedhere.
amsthm.styexplicitly defines handlers for\qedherefor the environmentsequation,equation*,displaymath,split,align,align*,gather, andgather*. Interestingly none is defined foralignatoralignat*. Secondly, if one just copy over verbatim the definition of the handler foralign*and try to use it foralignat*, one gets an incorrect result. So I am not sure whether the omission is an oversight or something deliberate. – Willie Wong Jul 20 '23 at 18:06alignat*would have been omitted from the applicable display structures. I've confirmed that this does indeed happen, and I'm quite puzzled. – barbara beeton Jul 20 '23 at 18:11amsthm.styandamsmath.styand I think I have a fix, though I don't have a full explanation why the current code should work (it seems rather hacky) foralign. (Basically it tries to place the tag using the same mechanism for bothalignandgather, which is strange as normally inamsmath.stythealigntype environments andgathertype environments have distinct methods for placing tags.) Anyway, I posted an answer below, feel free to edit / correct. – Willie Wong Jul 20 '23 at 20:05