[Math] Finding Boolean/Logical Expressions for truth tables

logic

I need to find the Boolean expression for the truth table below where $P$, $Q$, $R$ are inputs, and $S$ is the output. Does anyone have a cool easy way of solving such problems please? Your help will be appreciated.

$$\begin{array}{c|c|c||c}
P & Q & R & S\\
\hline
1 & 1 & 1 & 1\\
\hline
1 & 1 & 0 & 0\\
\hline
1 & 0 & 1 & 1\\
\hline
1 & 0 & 0 & 0\\
\hline
0 & 1 & 1 & 1\\
\hline
0 & 1 & 0 & 1\\
\hline
0 & 0 & 1 & 0\\
\hline
0 & 0 & 0 & 0
\end{array}$$

Best Answer

A mechanical way of getting an expression that has a desired truth table is to take the disjunction of the formulas that determine the rows you want with 1s.

For example, for a truth table on P, Q, and R that has $$\begin{array}{c|c|c||c} P & Q & R & \text{Table}\\ \hline 1 & 1 & 1 & 1\\ \hline 1 & 1 & 0 & 0\\ \hline 1 & 0 & 1 & 1\\ \hline 1 & 0 & 0 & 0\\ \hline 0 & 1 & 1 & 1\\ \hline 0 & 1 & 0 & 1\\ \hline 0 & 0 & 1 & 0\\ \hline 0 & 0 & 0 & 0 \end{array}$$ we note that the rows corresponding to $1$s are: $P\land Q\land R$, $P\land \neg Q\land R$, $\neg P\land Q\land R$, and $\neg P\land Q\land\neg R$. So a formula that has the desired truth table is $$(P\land Q\land R)\lor (P\land\neg Q\land R)\lor (\neg P\land Q\land R) \lor (\neg P\land Q\land \neg R).$$ This is, of course, unlikely to be the simplest formula that works, and may be simplified later.

Related Question