Is there a simple and intuitive way to drawn with latex this kind of tree?
I tried to check in the site "LATEX for LOGICIANS", but I can't find this kind of tree, with this kind of layout. Thank you
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIs there a simple and intuitive way to drawn with latex this kind of tree?
I tried to check in the site "LATEX for LOGICIANS", but I can't find this kind of tree, with this kind of layout. Thank you
Here's a forest style, smullyan tableaux
. The key closed
can be used when the style is active to close the current branch.
One advantage of forest is the concise bracket syntax used to specify trees.
\documentclass[tikz,border=10pt]{standalone}
\newcommand*\lif{\mathbin{\to}}% added thanks to egreg's suggestion
\usepackage{forest}
\forestset{
smullyan tableaux/.style={
for tree={
math content
},
where n children=1{
!1.before computing xy={l=\baselineskip},
!1.no edge
}{},
closed/.style={
label=below:$\times$
},
},
}
\begin{document}
\begin{forest}
smullyan tableaux
[\lnot(\lnot(A \land B) \lif (\lnot A \lor \lnot B))
[\lnot(A \land B)
[\lnot(\lnot A \lor \lnot B)
[\lnot\lnot A
[\lnot\lnot B
[A
[B
[\lnot A, closed]
[\lnot B, closed]
]
]
]
]
]
]
]
\end{forest}
\end{document}
Note that it is more usual in logic, as far as I know, to draw trees so that branches start from a common point:
This can be achieved, if necessary, by adding
parent anchor=south,
child anchor=north,
to the style.
\newcommand{\lto}{\mathbin{\to}}
so the arrow is treated as a binary operation (which it is, in this case).
\lif
is better than \lto
because it can be redefined to \supset
if necessary. (I know \lto
could be also, but \lif
is semantic whereas \lto
is format.)
Here is a simple code with pstricks
, and more specifically with pst-tree
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{pst-node, pst-tree, auto-pst-pdf}
\def\noedge{\ncline[linestyle = none]}
\renewcommand\psedge{\ncline[arrows =-]}
\begin{document}
\centering
\[ \psset{levelsep=1.2cm, treesep=2cm, nodesepA=10pt, nodesepB=2pt}
\pstree%
{\TR[vref =-1.25]{%
\makebox[0pt]{$ \begin{matrix}\neg(\neg(A\wedge B)\to(\neg A\vee\neg B))\\
\neg(A\wedge B)\\
\neg(\neg A\vee\neg B) \\
\neg\neg A\\
\neg\neg B\\
A\\B\end{matrix} $}}}%
{%
\TR[vref=1, href=2]{$ \begin{matrix} \neg A\\ \times\end{matrix}$}
\TR[vref=1, href=-2]{$ \begin{matrix} \neg B\\ \times \end{matrix}$}
} \]
\end{document}