Proof environment: problem with \popQED and \pushQED{\qed}

I was trying to replace . with : in the proof environment and after trying a lot of answered questions here, I got [I'm using amsmath]

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\itshape
{\popQED\endtrivlist\@endpefalse}
\makeatother


but this isn't working very well for me. After dozens of tries, I came up with

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\itshape
{\endtrivlist\@endpefalse}
\makeatother


So, what is the problem with \pushQED{\qed} and \popQED? Without both of them, the code works, but I can't get the qed square.

-
What's "not working well" in the first case? –  egreg Jan 29 '13 at 7:37
–  egreg Jan 29 '13 at 8:06
An easier way to get a colon is to say \renewcommand{\proofname}{Proof:}. Something more complex is needed if you use babel, but the idea is the same. –  egreg Jan 29 '13 at 9:23
@egreg Not working well is one of this message per proof "! Undefined control sequence. \\proof [#1]->\par \pushQED {\qed } \normalfont \topsep 6\p@ \@plus 6\p@ \re... l.167 T" Thank you for the good reception! And yes, I think I'm going to need the "something more complex", because I'm using [brazil]{babel}. Also, I commented the babel and tried the solution you gave and I got "Proof:.". –  Alexandre Campos Jan 29 '13 at 11:48

This seems to work without any problem; note that you must load amsthm.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\begin{document}

\begin{proof}
\end{proof}

\end{document}


Alternative and perhaps better version:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\makeatletter
\renewenvironment{proof}[1][\proofname]
{\par\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\itshape
{\popQED\endtrivlist\@endpefalse}
\makeatother

\begin{document}

\begin{proof}
\end{proof}

\end{document}


Another different version with patching (but it's just the same as the one before).

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\usepackage{xpatch}
\makeatletter