2

I'm working on a logic assignment, and I'm supposed to use LaTeX. In the assignments, I often need to be able to write something like what's below. I know how to do the table it's showing, but not bars, especially when there are in-lined proofs. Also, what would I do if there were multiple premises? Thanks for your help!

Logical proof of (P -> (Q ^ R)) ┠ (P -> R)

  • Will each "line" of the proof be exactly one typeset line, as shown above, or will occasionally a line of proof require more than one typeset line? – Steven B. Segletes Aug 25 '20 at 17:46
  • No, everything is in the same typeset. Also, indents always follow the pattern above as far as margins and lines. – BrainFRZ Aug 25 '20 at 18:12
  • I did not understand certain parts of your question. It would be really helpful if you could clarify what kind of output you are expecting for "in-lined proofs" and "multiple premises". I think even hand drawn figures should be fine. – Marvin Aug 29 '20 at 09:24
  • Doesn't this answer your problem? https://tex.stackexchange.com/questions/110328/formatting-a-logical-pd-derivation – Daniel Aug 31 '20 at 15:55

1 Answers1

4

Inside the provided myproof environment, use \z for a vertical bar, \z* for the vertical bar with the horizontal foot. The optional argument to myproof provides the indentation for \reason.

Because I redefine \par in the environment, you must use exactly one blank line between proof steps.

\documentclass{article}
\usepackage{tabto}
\def\zz{1.8\dimexpr}
\makeatletter
\newcommand\z{\@ifstar{\zstar}{\znostar}}
\makeatother
\newcommand\zstar{\makebox[1em][l]{%
  \smash{\rule[-\dimexpr2pt+\zz\dp\strutbox]{.5pt}{\zz\baselineskip}%
    \rlap{\rule[-\zz.9\dp\strutbox]{14pt}{.5pt}}}}\ignorespaces}
\newcommand\znostar{\makebox[1em][l]{%
  \smash{\rule[-\dimexpr2pt+\zz\dp\strutbox]{.5pt}{\zz\baselineskip}}}%
  \ignorespaces}
\let\svpar\par
\newcounter{proofline}
\newenvironment{myproof}[1][1.8in]{%
   \setcounter{proofline}{0}%
   \parskip0.8\baselineskip
   \def\reason{\tabto{#1}}%
   \def\par{\stepcounter{proofline}%
   \svpar\noindent\makebox[1.5em][l]{\theproofline}}%
   \par\ignorespaces
  }
  {\let\par\svpar
   \par\noindent
   \ignorespacesafterend
  }
\begin{document}
\noindent Before
\begin{myproof}
\z* $(P\rightarrow(Q\wedge R))$ \reason Premise

\z\z* $P$ \reason Assumption

\z\z $(Q\wedge R)$ \reason 1,2 $\rightarrow$E

\z\z $R$ \reason 3 $\wedge$E

\z $(P\rightarrow R)$ \reason 2-4 $\rightarrow$I \end{myproof} After

\noindent parskip was restored \end{document}

enter image description here