1

How can I typeset a proof in this style? That is, how can I write proofs with three columns, the first numbering the premise or assertion, the second containing the premise or assertion itself, and the third containing the justification of the assertion (if the second column of that row contains an assertion)?

enter image description here

Noah J
  • 515

2 Answers2

2

The following code is greatly indebted to gernot's answer to the question at Logical conditional proof (c.p.) arrows.

\suppose, \consequenceofsupposition, and \arrow (as defined below) are to be used for inferences that are justified by C.P. (conditional proof).

enter image description here

\documentclass{article}

\usepackage{calc} \usepackage{amssymb} % defines \therefore \usepackage{tikz}

\let\impl\supset

\newcounter{lineno} % as in ``line number''

\newcommand{\copiproof}[1]{\begin{center}\begin{tabular}{rll}\setcounter{lineno}{0}#1\end{tabular}\end{center}} % after Irving Copi

\newcommand{\premise}[1]{\addtocounter{lineno}{1}\thelineno. & $#1$\}

\newcommand{\premiseandclaim}[2]{% \addtocounter{lineno}{1}\thelineno. & $#1$ \rlap{\quad$/\therefore #2$}\}

\newcommand{\assert}[2]{\addtocounter{lineno}{1}\thelineno. & $#1$ & #2\}

\newcommand\tikznode[3][]{% \tikz[remember picture,baseline=(#2.base)] \nodeminimum size=0pt,inner sep=0pt,#1{#3};% }

\newcommand{\suppose}[1]{\addtocounter{lineno}{1}\tikznode{A}{\thelineno.} & $#1$\}

\newcommand{\consequenceofsupposition}[4]{\addtocounter{lineno}{1}\thelineno. & \tikznode{B}{$#1\impl(#2)$\strut} & $#3$--$#4$, C.P.\} % The first argument: the supposition. The second argument: the consequence of the supposition. The third argument: The line number of the supposition. The fourth argument: The line number of the consequence of the supposition.

\newcommand{\arrow}{% \begin{tikzpicture}[remember picture,overlay] \draw[stealth-,shorten <=2pt] (A) -- ++(-1.5em,0) |- (B.north east); \end{tikzpicture} }

\begin{document}

%%% Example skeleton:

\copiproof{ \premise{first premise} \premise{second premise} \premiseandclaim{third premise}{claim} \assert{first assertion}{justification} \assert{second assertion}{justification} \assert{third assertion}{justification} }

%%% gernot's code:

\begin{center} \begin{tabular}{rll} 1. & $A\impl B$ \rlap{\quad$/\therefore A\impl (A\cdot B)$}\ \tikznode{A}{2.} & $A$ & supuesto \ 3. & $B$ & $1$, $2$, M.P.\ 4. & $A\cdot B$ & $2$, $3$, Conj.\ 5. & \tikznode{B}{$A\impl(A\cdot B)$\strut} & $2$--$4$, C.P. \end{tabular} \end{center} \begin{tikzpicture}[remember picture,overlay] \draw[stealth-,shorten <=2pt] (A) -- ++(-1.5em,0) |- (B.north east); \end{tikzpicture}

%%% Mechanized version of gernot's code:

\copiproof{ \premiseandclaim{A\impl B}{A\impl (A\cdot B)} \suppose{A} \assert{B}{1, 2, M.P.} \assert{A\cdot B}{2, 3, Conj.} \consequenceofsupposition{A}{A\cdot B}{2}{4} \arrow }

\end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Noah J
  • 515
2

Here is a solution with {NiceTabular} of nicematrix and TikZ to draw the arrows with the TikZ nodes created by nicematrix.

\documentclass{article}
\usepackage{amssymb} % for \therefore
\usepackage{nicematrix,tikz}
\usetikzlibrary{arrows.meta,ext.paths.ortho} % for "r-lr"

\begin{document}

\begin{NiceTabular}{rll}

  1. & $A\supset B$ \rlap{\quad$/\therefore A\supset (A\cdot B)$}\
  2. & $A$ & supuesto \
  3. & $B$ & $1$, $2$, M.P.\
  4. & $A\cdot B$ & $2$, $3$, Conj.\
  5. & $A\supset(A\cdot B)$ & $2$--$4$, C.P.

\CodeAfter \tikz \draw [<-,shorten < = 2pt] (2-1) r-lr ([yshift=1pt]5-|3); \end{NiceTabular}

\end{document}

Output of the above code

F. Pantigny
  • 40,250