2

What is the way to write a proof like the one in the image? enter image description here

I know how to write all the symbols, but I don't know how to make the rectangle and write like a table. I used this webpage: https://www.tablesgenerator.com/, but I don't like how it displays the proofs.

Mystery
  • 123
  • In your tex editor (e.g. Texstudio, or Texmaker), you'd probably find a visual menu of symbols on the left with all what you are asking for. – hesham Mar 27 '20 at 23:19
  • Otherwise, are you asking how to write in math mode? For example there is a lot of environments that you can use, such as \begin{equation}, \begin{align}, \begin{proof}, etc. So be specific in your question about the difficulty that you are facing. – hesham Mar 27 '20 at 23:21
  • I already edited my question. – Mystery Mar 27 '20 at 23:23
  • Perhaps this can help you. – gjkf Mar 27 '20 at 23:30

2 Answers2

2

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:

  1. The first one automatically displays the number of the row of the proof (you don't have to write anything in it);
  2. The second one is automatically in math mode and is thought to be used for steps of the proof;
  3. 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}

Vincent
  • 20,157
1

Assuming no issues in writing the symbols commands, then you can use empheq package to make a box around some equations (two for simplicity) like this:

enter image description here

And its code

\documentclass{article}
\usepackage{amsmath}
\usepackage{empheq}
\begin{document}
%
\begin{empheq}[box=\fbox]{align}
    E=mc^2 \\
    y=ax+b
\end{empheq}
%
\end{document}

And of course you can add an asterisk {align*} to remove the numbering of equations.

If you want equations numbering left-side, you can use the option [leqno] of the article class like this

enter image description here

with some equations numbered and others not (use \nonumber), then the code can be

\documentclass[leqno]{article}
\usepackage{amsmath}
\usepackage{empheq}
\begin{document}
%
\begin{empheq}[box=\fbox]{align}
    E=mc^2 \\
    y=ax+b \\
    y_2 = ax+b \nonumber
\end{empheq}
%
\end{document}

Well, that's not the perfect answer. It's just some ideas that I am sure others can improve.

hesham
  • 1,443
  • 1
    Okay, but how can I add a symbol in the corners and how can I add numbers at the left like in the image of my question? – Mystery Mar 27 '20 at 23:44
  • That's for left-side numbering. Perhaps for adding symbols in the corner I will leave that for someone else to help. Good luck! – hesham Mar 27 '20 at 23:59