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}

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.
0
and1
's. Going toT
andF
isn't a problem, but what is more serious is that you are assigning truth values to sub-expressions. A modification of the\xintexpr
parser, dealing with sequences ofT
's` andF
's could do it, but would be a bit of overkill, as it would allow permissiveP 'and' Q 'or' 'not' R 'and' S
or parentheses arising from expansion. With a stricter input syntax such as(P and Q) or (not(R) and S)
it is much easier, (continued) – user4686 Jan 11 '16 at 9:40(\P\AND\Q)\OR(\NOT(\R)\AND\S)
then it would be almost a breeze. (especially if we do not insist on treating it completely expandably). – user4686 Jan 11 '16 at 9:41