# Coming up with an expression given the truth table

I have been given a truth table. I want find a boolean expression for it. However , I am not able to come up with one. Is there a specific way to go about , in order to get it done ? Also, Can this solution be possible using a single ssi 7400 chip ? (max of 4 nand gates)

## 1 Answer

$$C \wedge (A \vee \neg B)$$

By looking at the TT you can easily see that $\phi(A,B,C) \Rightarrow C$ wich means that $\phi \equiv C \wedge ?$. The rest is simple.

If you only want to come up with some formula, regardless of the number of conjuctives, the TT can be directly translated to a formula in CNF. (It has $2^n$ clauses each with $n$ literals for a total of $(n-1)2^n + 2^n - 1 = n2^n - 1$ gates. This case would result in $23$ gates compared to the two we actually needed)

To arrive at a circuit using 4 NAND gates we remember (using $\sqcap$ for NAND):

$$A \sqcap A = \neg A \\ A \wedge B = \neg (A \sqcap B) = (A\sqcap B)\sqcap(A\sqcap B)\\ A \vee B = \neg A \sqcap \neg B$$

Where the middle one only needs two NAND gates by reusing the result of $A\sqcap B$.

\begin{align*} C \wedge (A \vee \neg B) & \stackrel{(3)}\equiv C \wedge (\neg A \sqcap B) \\ & \stackrel{(1)}\equiv C \wedge ((A\sqcap A) \sqcap B) \\ & \stackrel{(2)}\equiv (C\sqcap((A\sqcap A) \sqcap B)) \sqcap (C\sqcap((A\sqcap A)\sqcap B)) \end{align*}

So this is possible with 4 NAND gates on your chip.

• How did you come up with an answer this quickly ? – harveyslash Sep 15 '15 at 21:00
• @user2670775 Practice ^^ There is an algorithm as well, but it needs many more gates (read about CNF if you're interested). – AlexR Sep 15 '15 at 21:04
• But how does one use 4 nand gates (and 4 only) to get the same output given the same input ? – harveyslash Sep 15 '15 at 21:10
• @user2670775 is a not gate allowed? – AlexR Sep 15 '15 at 21:14
• @user2670775 I actually consider my second solution to have taken "too much time" ^^ I played around with MATLAB to represent the standard conjunctives used in my original solution by NANDs, since I'm not really thinking in terms of NANDs. After figuring out the three rules above it was just a matter of plugging in and checking that we only need four NANDs. – AlexR Sep 15 '15 at 21:45