[Tex/LaTex] Resolution trees in latex

resolutiontikz-trees

I would like to draw a resolution tree such as this.
resolution proof

I have already seen this post and I could make trees like the example shown in that. However, I do not know how to point to a child node from multiple parent nodes using the qtree style. This is my MWE.

\documentclass[tikz, margin=10pt]{standalone}
\usepackage{tikz-qtree}
\usepackage{latexsym}

\begin{document}
\begin{tikzpicture}[grow'=up]
\Tree [.$\Box$ [.${\{m\}}$ [.${\{a,m\}}$ ${\{3,4\}}$ ${\{5,6\}}$ ]
                           [.${\{ \neg a\}}$ ${\{8\}}$ ${\{7, \neg a\}}$ ] ]
                           [ [.${\{\neg m\}}$ ${\{ \neg c\}}$ ${\{c, \neg m\}}$ ] ] ]
\end{tikzpicture}
\end{document}

Best Answer

Multiple parents to single child is done manually by adding edges to the nodes. So you build your tree as usual, and assign (easy to remember) node names to each or only to those nodes you need.

After the tree is done, inside the tikzpicture you can then draw the extra lines.

This is possible both with Tikz-qtree and with Tikz trees. I made a random edge just to show you how it's done (coloured in red). Feel free to modify as you need it.

Tikz-qtree

Output

enter image description here

Code

\documentclass[tikz, margin=10pt]{standalone}
\usepackage{tikz-qtree}
\usepackage{latexsym}

\begin{document}
\begin{tikzpicture}[grow'=up]
\Tree [.$\Box$ [. \node(m1){${\{m\}}$}; [.${\{a,m\}}$ ${\{3,4\}}$ ${\{5,6\}}$ ]
                           [.${\{ \neg a\}}$ ${\{8\}}$ ${\{7, \neg a\}}$ ] ]
                           [ [.\node(m2){${\{\neg m\}}$}; ${\{ \neg c\}}$ ${\{c, \neg m\}}$ ] ] ]

\draw[red] (m1.north) -- (m2.south);
\end{tikzpicture}
\end{document}

Tikz trees

Output

enter image description here

Code

\documentclass[tikz, margin=10pt]{standalone}
\usetikzlibrary{trees}

\tikzset{
    every node={circle,draw}
}


\begin{document}
\begin{tikzpicture}[level distance=1.5cm,
level 1/.style={sibling distance=3.5cm},
level 2/.style={sibling distance=1cm}]

\node (Root) {1}
    child {
    node (n2) {2} 
    child { node (n4) {4} }
    child { node (n5) {5} }
}
child {
    node (n3) {3}
    child { node (n6) {6} }
    child { node (n7) {7} }
};

\draw (n2) -- (n6);
\draw (n3) -- (n5);
\end{tikzpicture}
\end{document}
Related Question