Need \qedhere to be flush with the right margin in cases environment

Abuse gathered:

\documentclass{amsart}
\usepackage{amssymb, amsmath, amsthm}

\newtheorem{theorem}{Theorem}
\newtheorem*{ut}{Theorem}

\begin{document}

\begin{proof}
\[
\begin{gathered}[b]
X(m,n)=
\begin{cases}
x(n),\\
x(n-1)\\
x(n-1)
\end{cases}
\\
\end{gathered}
\qedhere
\]
\end{proof}

\begin{ut}The sky is blue.\end{ut}

\begin{proof}Duh.\end{proof}

\end{document}

In my opinion this is not the right place, as the baseline should be determined by X(m,n).

enter image description here


You could place the \qedhere outside the cases and raise the box. Or, see follow up to avoid having to recalculate the raise amount for each different cases environment.

\documentclass{amsart}
\usepackage{amssymb, amsmath, amsthm}

\newtheorem{theorem}{Theorem}
\newtheorem*{ut}{Theorem}

\begin{document}

\begin{proof}

\[
\raisebox{1.2\baselineskip}{$\displaystyle
X(m,n)=
\begin{cases}
x(n),\\
x(n-1)\\
x(n-1)
\end{cases}$}
\qedhere
\]
\end{proof}

\begin{ut}The sky is blue.\end{ut}

\begin{proof}Duh.\end{proof}

\end{document}

enter image description here

FOLLOW UP:

If you didn't want to have to calculate the shift each time, you could use the stackengine package, with \abovebaseline[-\dp\strutbox]{...} in lieu of the \raisebox{shift length}{...}.


Following @egreg's suggestion as to the placement of the qed symbol, there's almost nothing to do: just replace $$ … $$ with \[ … \]. One more illuùminating example of why the latter is preferable:

\documentclass{amsart}
\usepackage{amssymb, amsmath, amsthm}

\newtheorem{theorem}{Theorem}
\newtheorem*{ut}{Theorem}

\begin{document}

\begin{proof}[Proof 1]

  \[
    X(m,n)=
    \begin{cases}
      x(n), \\ x(n-1)\\ x(n-1)
    \end{cases}
    \qedhere
  \]
\end{proof}
\vskip4ex

\begin{proof}[Proof 2]

  $$
  X(m,n)=
  \begin{cases}
    x(n), \\ x(n-1) \\ x(n-1)
  \end{cases}
  \qedhere
  $$

  \begin{ut}The sky is blue.\end{ut}

  \begin{proof}Duh.\end{proof}

\end{proof}

\end{document} 

enter image description here