Here's a solution using a tabular environment. For the simplicity of the code of the proof itself, I defined some new commands. First, an environment prooftabular which begins a tabular with three columns:
- The first one automatically displays the number of the row of the proof (you don't have to write anything in it);
- The second one is automatically in math mode and is thought to be used for steps of the proof;
- The third one is in text mode and is thought to be used for the justifications of the steps of the proof.
This environment could be used alone to display a proof. However, to add the box with the symbols in the corner, I defined three other commands:
\hlineproofbox adds the horizontal lines of the box with \cline{2-2}.
\proofboxed adds the vertical lines around a cell in the box. It takes as an argument the content of the corresponding cell. It only adds the vertical lines with a \multicolumn{1}{|...|}{...}.
\corner adds its argument in superscript, in the corner. It should be placed inside of the first \proofboxed{}.
These three commands are not so useful in the sense that their content could as well have been placed directly in the table. I just thought the code of the proof was easier to read this way.
Anyway, here's a complete example with your proof.
\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\newcounter{proofrow}
\newenvironment{prooftabular}{%
\let\oldarraystretch\arraystretch
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{%
@{\stepcounter{proofrow}\theproofrow}%
p{1em}@{}>{\(}l<{\)}>{\quad}l%
}
}{%
\end{tabular}
\renewcommand{\arraystretch}{\oldarraystretch}
}
\newcommand{\hlineproofbox}{\cline{2-2}}
\newcommand{\proofboxed}[1]{\multicolumn{1}{|>{\(}l<{\)}@{\ }|}{#1}}
\newcommand{\corner}[1]{\qquad {}^{#1}}
\begin{document}
\[
\forall x, P_1^1(x) \implies P_2^1(x), \forall x . P_2^1(x) \implies P_3^1(x) \vdash \forall x . P_1^1(x) \implies P_3^1(x)
\]
\begin{prooftabular}
& \forall x . P_1^1(x) \implies P_2^1(x) & Prem \\
& \forall x . P_2^1(x) \implies P_3^1(x) & Prem \\
\hlineproofbox
& \proofboxed{P_1^1(n) \implies P_2^1(n) \corner{/ \forall n}} & \(E \ \forall 1\) \\
& \proofboxed{P_2^1(n) \implies P_3^1(n)} & \(E \ \forall 2\) \\
& \proofboxed{P_1^1(n) \implies P_3^1(n)} & Teo \(\alpha \implies \beta, \beta \implies \gamma \vdash \alpha \implies \gamma\) \\
\hlineproofbox
& \forall x . P_1^1(x) \implies P_3^1(x) & \(\forall x . P_1^1(x) \implies P_2^1(x), \forall x . P_2^1(x) \implies P_3^1(x)\)
\end{prooftabular}
\end{document}
