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?
Asked
Active
Viewed 1,252 times
0
cfr
- 198,882
2 Answers
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}
egreg
- 1,121,712
-
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. – Apr 05 '16 at 07: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 Apr 05 '16 at 07: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. – Apr 05 '16 at 08:02
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}
-
-
-
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.
– Apr 05 '16 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 Apr 05 '16 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 Apr 05 '16 at 23:58
-
Ok, you don't mind doing most of the work that you enjoy as long as you don't have to do the little bits that you don't like. Kindly, noted. – Apr 05 '16 at 23:59
-
@crocket I think this is quite common. People enjoy puzzles. They don't like setting them up. At least, it seems quite common among people who answer questions on this site. And remember that the formulae don't have meaning for all the potential helpers. I sometimes answer questions where the content means essentially nothing to me. If I have to figure out how to input Arabic, I'm not going to answer. Wffs happen to have meaning for me but other formulae don't. So what is a little bit for the asker may be a lot for potential answerers. Practically impossible in some cases. – cfr Apr 06 '16 at 00:08



picturemode. – egreg Apr 05 '16 at 06:35\begin{picture}...\end{picture}environment defined in standard LaTeX. – egreg Apr 05 '16 at 06:48You tell LaTeX where to put things in the picture by specifying their coordinates.I expect it to require calculating locations of each little bit. I can't manually calculate the coordinates of all the little things in such a tree. – Apr 05 '16 at 06:51treesortikz-qtreeor whatever. But you already know Forest and it is more flexible. – cfr Apr 05 '16 at 11:56