0

The following parsing tree is from Mathematical Logic published in 2007 and written by Ian Chiswell & Wilfrid Hodges. It looks like a forest tree, but I guess it could be typeset better by another package. How shall I typeset this?

enter image description here

9
  • Maybe a slight variation on this? But please provide a minimal example which at least provides the basics. It is not as if you don't know where to start!
    – cfr
    Commented Apr 4, 2016 at 21:48
  • @cfr Your link seems to be very close to what I want. This tree is so alien to plain forest that I don't know how to provide a minimal example. All I know for now is that this tree encroaches into the realm of tikz and that I may have to learn tikz from scratch. Would tikz alone be better than the combination of tikz and forest?
    – user82730
    Commented Apr 5, 2016 at 4:31
  • This has probably been realized with picture mode.
    – egreg
    Commented Apr 5, 2016 at 6:35
  • @egreg Do you mean ctan.org/pkg/picture ? What is picture mode? I need more information.
    – user82730
    Commented Apr 5, 2016 at 6:46
  • @crocket The standard \begin{picture}...\end{picture} environment defined in standard LaTeX.
    – egreg
    Commented Apr 5, 2016 at 6:48

2 Answers 2

3

Using more-or-less the formulae kindly transcribed from the do-it-for-me image by egreg when the OP failed to provide any help whatsoever, together with a tweaked version of the tableaux style I developed for this answer, I drew a version of the tree using Forest as follows. For the record, I think I ought not answer this question but I'm giving in to my fascination with trees.

\documentclass[border=5pt,tikz,multi]{standalone}
\usepackage{forest}
\newcommand*{\lif}{\ensuremath{\mathbin{\rightarrow}}}
\forestset{%
  declare toks={wff}{},
  declare toks={cyswllt}{},
  declare toks register={nod safonol},
  nod safonol=\circ,
  dosbarthu/.style={%
    for tree={
      math content,
      parent anchor=children,
      child anchor=parent,
      inner sep=0pt,
    },
    where level=0{%
      for children={no edge},
      phantom,
    }{%
      delay={%
        content'/.register=nod safonol,
        insert before/.wrap pgfmath arg={%
          [{##1}, no edge, math content, before drawing tree={x'+=7.5pt}]
        }{wff()},
        if={strequal(cyswllt(),"")}{cyswllt/.option=wff}{},
        insert after/.wrap pgfmath arg={%
          [{##1}, no edge, math content, before drawing tree={x'-=7.5pt}]
        }{cyswllt()},
      },
      if={n_children("!parent")==1}{%
        before packing={calign with current edge},
      }{%
        if n=1{%
          before packing={%
            !parent.calign primary child/.process args={O}{n},
          },
        }{%
          before packing={%
            !parent.calign secondary child/.process args={O}{n},
          },
       }
      }
    },
  }
}
\begin{document}
\begin{forest}
  dosbarthu
  [
    [, wff=((\lnot(p_1\lif(\lnot p_0)))\lif p_0), cyswllt=\lif
      [, wff=(\lnot(p_1\lif(\lnot p_0))), cyswllt=\lnot
        [, wff=(p_1\lif(\lnot p_0)), cyswllt=\lif
          [, wff=p_1]
          [, wff=(\lnot p_0), cyswllt=\lnot
            [, wff=p_0]
          ]
        ]
      ]
      [, wff=p_0]
    ]
  ]
\end{forest}
\end{document}

coeden ddosbarthu (dyw neb arall yn 'sgrifennu unrhywbeth o gwbl felly, 'sbo'r Gymraeg yn iawn!)

7
  • I like ”safonol“ and “dosbarthu”! :)
    – egreg
    Commented Apr 5, 2016 at 22:51
  • More pronounceable than 'cyswllt'? ;)
    – cfr
    Commented Apr 5, 2016 at 22:55
  • The best I could do was drawing a plain forest tree with left labels and right labels mingled into one node, and I thought it would be hardly any different from just listing the propositional formulas line by line because the 99.9% of work lies in the clever forest/TikZ structure, but not in the propositional formulas. I thought giving you 0.01% of the work wasn't going to make anyone feel better.
    – user82730
    Commented Apr 5, 2016 at 23:52
  • @crocket Copying propositional formulae from an image in another application on another virtual desktop into my editor takes a lot of effort and time. Copying code for the same formulae takes seconds. Even for somebody with sufficient screen real estate to display the image and the editor simultaneously, it is probably annoying. To constantly need to switch applications or desktops drives me nuts. However, I didn't. I copied egreg's. A list would be good. A tree even better. Nothing sucks.
    – cfr
    Commented Apr 5, 2016 at 23:55
  • @crocket To put this another way: writing the Forest/TikZ stuff to structure the tree is the puzzle. That's interesting/challenging. Copying the content in order to set the puzzle up is boring/easy/frustrating.
    – cfr
    Commented Apr 5, 2016 at 23:58
3

Picture mode is sufficient; pict2e is loaded for better compatibility with newer engines.

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e,color}

\begin{document}

\begin{equation}
\begin{gathered}
\setlength{\unitlength}{0.5in}
\begin{picture}(5,4)
\put(5,3){\line(-3,2){1.5}}
\put(3.5,4){\line(-3,-2){1.5}}
\put(2,3){\line(0,-1){1}}
\put(2,2){\line(-1,-1){1}}
\put(2,2){\line(1,-1){1}}
\put(3,1){\line(0,-1){1}}
\begingroup\color{white}
\put(5,3){\circle*{0.1}}
\put(3.5,4){\circle*{0.1}}
\put(2,3){\circle*{0.1}}
\put(2,2){\circle*{0.1}}
\put(1,1){\circle*{0.1}}
\put(3,1){\circle*{0.1}}
\put(3,0){\circle*{0.1}}
\endgroup
\put(5,3){\circle{0.1}}
\put(3.5,4){\circle{0.1}}
\put(2,3){\circle{0.1}}
\put(2,2){\circle{0.1}}
\put(1,1){\circle{0.1}}
\put(3,1){\circle{0.1}}
\put(3,0){\circle{0.1}}
\put(5,3){\makebox(0,0){$p_0$\qquad$p_0$}}
\put(3.15,4){\makebox(0,0){\makebox[0pt][r]{%
  $((\lnot(p_1\mathbin{\to}(\lnot p_0)))\mathbin{\to}p_0)$}}%
}
\put(3.7,4){\makebox(0,0){\makebox[0pt][l]{$\to$}}}
\put(1.65,3){\makebox(0,0){\makebox[0pt][r]{%
  $(\lnot(p_1\mathbin{\to}(\lnot p_0)))$}}%
}
\put(2.2,3){\makebox(0,0){\makebox[0pt][l]{$\lnot$}}}
\put(1.65,2){\makebox(0,0){\makebox[0pt][r]{%
  $(p_1\mathbin{\to}(\lnot p_0))$}}%
}
\put(2.2,2){\makebox(0,0){\makebox[0pt][l]{$\to$}}}
\put(1,1){\makebox(0,0){$p_1$\qquad$p_1$}}
\put(2.65,1){\makebox(0,0){\makebox[0pt][r]{$(\lnot p_0)$}}}
\put(3.2,1){\makebox(0,0){\makebox[0pt][l]{$\lnot$}}}
\put(3,0){\makebox(0,0){$p_0$\qquad$p_0$}}
\end{picture}
\end{gathered}
\end{equation}

\end{document}

enter image description here

3
  • I appreciate the demonstration, but the code is verbose and involves lots of manual coordinate accounting that I want to automate away with a package. I want the code to reflect the logic structure to a degree concisely.
    – user82730
    Commented Apr 5, 2016 at 7:56
  • @crocket You may want something, but you're being very impolite. You asked how to typeset that diagram, not “is it possible to have a generic way to typeset alike diagrams, with minimal effort?”
    – egreg
    Commented Apr 5, 2016 at 7:58
  • Sorry for being impolite. I have used a lot of mental energy on mathematics today, so I don't have much mental energy left for socialization and diplomacy. Diplomacy and creativity require the same kind of mental energy. I think forest and pgf/tikz might be more appropriate for elegant code.
    – user82730
    Commented Apr 5, 2016 at 8:02

You must log in to answer this question.