That's a lot of functions. For example, the number of functions with 2 bits of inputs and 1 bit of output is 16. For 10 bits, there are 21024 different functions!
However, we don't make a gate for each different Boolean function. In fact, very few Boolean functions have gates associated with it. Of the 16 possible, 2- bit input, 1-bit output Boolean functions, only 6 are gates (AND2, OR2, XOR2, NAND2, NOR2, XNOR2). Here's an amazing fact---you only need three gates to implement all Boolean functions.
Let's repeat that once again: you only need three gates to implement all Boolean functions.
If you find that hard to believe, it's true, and it's quite amazing. In particular, we're only going to need AND2, OR2, and NOT. Any Boolean function can be constructed using an arbitrary number of inputs plus an arbitrary number of these gates.
Here's an example.
| Row | x2 | x1 | x0 | z |
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 |
| 2 | 0 | 1 | 0 | 0 |
| 3 | 0 | 1 | 1 | 0 |
| 4 | 1 | 0 | 0 | 0 |
| 5 | 1 | 0 | 1 | 1 |
| 6 | 1 | 1 | 0 | 0 |
| 7 | 1 | 1 | 1 | 0 |
In the truth table above, row 5 has output 1. The rest of the rows have output 0.
Before we answer this question, let's define a literal.
Definition A literal is either a variable or its negation. Thus, both x and \x are literals. (\x is x, preceded by a prime, which indicates negation).
We'll assume that \\x or \\\x are not literals, even though they are equivalent to literals.
There are some interesting properties of literals.
To construct this function, it looks like we need to AND some subexpressions. That's true.
Consider the following Boolean function: x2 * x1 * x0. This function is the conjuction (or ANDing) of three positive literals. We use multiplication to indicate AND2.
When does this function produce 1 as output? It produces it when x2 = 1 AND x1 = 1 AND x0 = 1. For any other combination of values, the output is 0.
Consider the following Boolean function: \x2 * \x1 * \x0. This function is the conjuction (or ANDing) of three negative literals.
When does this function produce 1 as output? It produces it when x2 = 0 AND x1 = 0 AND x0 = 0. For any other combination of values, the output is 0.
In fact, any conjunction (ANDing) of three literals produces a truth table with exactly one 1 as output. That makes sense, because AND suggests that all the literals have to be true in order for the entire expression to be true.
Let's define this kind of conjunction, and call it a minterm.
Definition A minterm of k variables is a conjunction of k literals, where each variable shows up exactly once.
A minterm produces a truth table that has exactly one 1 as output.
To construct a minterm, look at the row of the truth table you want to have output 1. If the value of the variable is 1, use a positive literal. If the value of the variable is 0, use a negative literal.
For example, in the truth table above, you have: x2 = 1 AND x1 = 0 AND x0 = 1. Thus, you need literals: x2, \x1, and x0. Conjoin them together, and you get: x2 \x1 x0.
As with most problems, the answer is to create solution using the solution we already have. We know that if you have a truth table with a single 1 as output, you use a single minterm. If you have a truth table with m 1's as outputs, it makes sense to use m minterms.
In fact, that's how we do it.
| Row | x2 | x1 | x0 | z |
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 |
| 2 | 0 | 1 | 0 | 1 |
| 3 | 0 | 1 | 1 | 0 |
| 4 | 1 | 0 | 0 | 0 |
| 5 | 1 | 0 | 1 | 1 |
| 6 | 1 | 1 | 0 | 0 |
| 7 | 1 | 1 | 1 | 1 |
In the truth table above, rows 2, 5, and 7 have outputs of 1. We need to construct a minterm for each of the rows.
| Row | Minterm |
| 2 | \x2 x1 \x0 |
| 5 | x2 \x1 x0 |
| 7 | x2 x1 x0 |
Then, join the minterms with ORs to get the final Boolean function.
As you've noticed, we've put all the terms together with ORs (written as +). This makes sense. The entire expression is true if any one of the minterms is true.
First, you can just define the Boolean function to be 0. This can be considered a constant function that takes no arguments, and always produces a constant value.
z = 0
Or, if you don't want to use constants, you can do:
z = x\x
In this version, you take a positive and negative literal and AND them. There's no way to make a variable and its negation both true.
In general, the z = 0 is preferable because it's simpler.
This is considered a canonical or standard form for the truth table. This particular form is called sum of products, or sum of minterms or disjunctive normal form (a disjunct are terms connected by ORs---in this case, the terms are minterms).
However, a product term is more general than a minterm. A product term is a conjunction of any number of literals. Usually, no variable shows up twice in a product term, though it is a possibility.
The following is an example of a sum of products: x + xy + x\z + \x\yz.
There are four product terms in the sum: x, xy, x\z, and \x\yz. However, the product terms aren't considered minterms because the number of literals isn't the same for all product terms. In a sum of minterms of k variables, all the products terms must have k literals.
We can even allow variables to be repeated in a product term. Thus, we allow x\x as a product term, even though it's not permitted as a minterm, where each variable can only show up once.
There is a similar analog to a product term called a sum term.
We won't discuss minimization.