[Tex/LaTex] How to display verification of propositional logic in this way

amsmathlogic

I want to typeset something like the following picture.

enter image description here

I came up with

\documentclass[oneside,12pt]{article}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\begin{document}
\[
  \begin{aligned}
    &\neg&(P &\wedge&R)\\
    &T&&F&\\
  \end{aligned}
\]
\end{document}

How can I typeset a table like the above one?

Best Answer

Logic is not all that well supported in LaTeX, unfortunately. At least, if it is, I haven't managed to track down the support. Everything always seems to involve a solution intended for some other problem and making it do something else.

If you have the patience, you could use something like this. I find tabular less hassle than a maths environment because all the Ts and Fs and Ps and Qs and so on need to be in what is essentially a text font anyway. (At least if your text font is also used for operators and so on in maths mode, which is usual.) And switching into maths mode for other things is less of a pain than typing \text{} all the time for text mode.

\documentclass[oneside,12pt]{article}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\begin{document}
  \begin{tabular}{*{4}{c}|r@{}ccc@{\thinspace}r@{}*{3}{c}@{\thinspace}c@{}lcr@{}*{3}{c}@{\thinspace}c@{\thinspace}c@{}l}
  P&Q&R&S&$(\{$&S&$\land$&$\lnot$&$($&Q &$\land$& $\lnot$&P&$)\}$&$\lor$&$\{$&R&$\lor$&$\lnot$&$\lnot$&Q&$\})$\\\hline
  T&F&F&F& &F&F&T&& F&F&F&T &&F &&F&F&F&T&F\\
\end{tabular}
\end{document}

truth table line

There are scripts which will produce the tables for you, but if you are learning logic, that's no good because you need to figure out the tables for yourself. If you are teaching logic, on the other hand, they can be very useful. They don't do the spacing adjustments I included here, either. At least, the one I used didn't.