3.4 On sets, off sets and the uniting theorem
Why this matters
A truth table says what a circuit must do, and the most direct formula you can write from it is as long as the table. Real designs need something smaller, because every extra term is another gate. This section shows the one algebra step that shrinks a formula, and it shows which pairs of rows it works on. The next two sections turn that step into a drawing you can do quickly by hand.
Learning goals
Section titled “Learning goals”- Name the on set and the off set of a function from its truth table.
- Write a sum of products from the on set and a product of sums from the off set.
- Identify neighboring input patterns, which differ in exactly one input.
- Merge two neighboring patterns into one smaller term with the uniting theorem.
- Explain why scanning a truth table is a poor way to find neighbors.
Intuition first
Section titled “Intuition first”Think of a truth table as a guest list. The rows where F is 1 are the names on the list, and a circuit for F is a doorman: it must say yes to every name on the list and no to everyone else. The most direct doorman hires one checker per name. Each checker recognizes exactly one input pattern, and an OR gate at the end says yes when any checker does. That circuit is correct, and it is exactly as big as the list.
Software has the same shape. A test written as a == 0 && b == 0 && c == 1 || a == 0 && b == 1 && c == 1 is really just a == 0 && c == 1, because the test says yes for both values of b, so b does not matter. Hardware gets the same saving, with one difference: all the gates in a circuit work at the same time, so nothing is skipped. What you save is gates and wires.
The question for this section is how to notice, in a table, which checkers can be merged.
On sets and off sets
Section titled “On sets and off sets”The on set of a function is the set of input patterns for which the function is 1. The off set is the set of input patterns for which it is 0.
A function with no don't-care outputs puts every input pattern in exactly one of the two sets. (Section 3.7 adds a third group for patterns whose output does not matter.)
Figure 3.4.1 shows a function F of three inputs with the rows of its on set highlighted. The on set is the four patterns where A, B and C are 001, 011, 100 and 101. The off set is the other four: 000, 010, 110 and 111.
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 |
Description: A truth table of F with inputs A, B and C. Four of the eight rows are highlighted: the rows where A, B and C are 0 0 1, 0 1 1, 1 0 0 and 1 0 1.
A sum of products from the on set
Section titled “A sum of products from the on set”The on set tells you directly how to build the doorman. Each pattern in it gets one checker, which is a product of all the inputs.
The sum of products from the on set has one product term for each pattern in the on set. The term is 1 on that pattern and 0 on every other pattern: each input appears plain if it is 1 in the pattern and with a bar if it is 0. The function is the OR of these terms.
For the pattern 001 of F the term is : A and B are 0, so they carry bars, and C is 1, so it does not. Doing the same for the other three patterns and adding the results gives
This is correct, because on every on-set pattern exactly one of the terms is 1, and on every off-set pattern none is. It also has four terms of three variables each, which is as large as the on set.
A product of sums from the off set
Section titled “A product of sums from the off set”The off set gives a second recipe. Instead of listing the patterns where the answer is yes, list the patterns where it is no, and write a check that fails on exactly one of them.
The product of sums from the off set has one sum term for each pattern in the off set. The term is 0 on that pattern and 1 on every other pattern: each input appears plain if it is 0 in the pattern and with a bar if it is 1. The function is the AND of these terms.
The bars are the opposite way around from the product recipe, because a sum is 0 only when every one of its pieces is 0. For the off-set pattern 000 the sum is , which is 0 only when A, B and C are all 0. For 010 it is . Doing this for all four off-set patterns gives
An AND is 0 as soon as one factor is 0, so this is 0 on every off-set pattern. On any other pattern every factor is 1, so the whole product is 1. The two forms describe the same function: the sum of products is 1 on exactly the on-set rows, and the product of sums is 0 on exactly the off-set rows. The sum of products reads the ones of the table and the product of sums reads the zeros. Both are two-level forms: a layer of ANDs feeding one OR, or a layer of ORs feeding one AND.
Neighbors and the uniting theorem
Section titled “Neighbors and the uniting theorem”Two input patterns are neighbors if they differ in exactly one input.
A pattern of inputs has exactly neighbors, one for each input you could flip. The pattern 001 has three: 101 (flip A), 011 (flip B) and 000 (flip C).
Neighbors are interesting because of what happens to their terms. In F, the patterns 001 and 011 are both in the on set, and they differ only in B. Their two products are the same except for the bar on B, so B can be pulled out of the picture:
| Expression | Law used |
|---|---|
| Distributive | |
| Complement | |
| Identity |
Nothing special happened to B in that argument. Any two products that match in every variable except one, where one has the variable and the other has its complement, merge this way. That is the uniting theorem.
The uniting theorem says that if E is any expression that does not use B, then . Its dual for sums is . In words: two terms that differ only in whether B or its complement appears collapse into the part they share.
F has three neighbor pairs in its on set, and two of them are enough to cover it. The patterns 001 and 011 differ only in B and merge into , as the derivation above showed. The patterns 100 and 101 differ only in C. Both have A equal to 1 and B equal to 0, so they merge into . All four on-set patterns are now covered, and the sum of the two merged terms is the function: . Four terms of three variables became two terms of two.
There is a third neighbor pair, which also lies inside the on set: 001 and 101 differ only in A, and they merge into . A pattern can have several neighbors in the on set, and it can be merged with any of them. Here that extra term is not needed, because the first two merges already cover every on-set pattern: . Section 3.6 returns to this, because deciding which merges to keep is the whole skill of grouping.
The product of sums has its own version of the same move. In F, the off-set patterns 000 and 010 are neighbors that differ only in B.
The sums for 000 and 010 are and . Pulling out the shared part works the same way, with the dual form of the theorem:
| Expression | Law used |
|---|---|
| Commutative | |
| Distributive | |
| Complement | |
| Identity |
The other two off-set patterns, 110 and 111, differ only in C and merge into . Together the two merged sums cover the whole off set, and the result is the same function again: . This product of sums has two sums of two variables each, and the sum of products above has two products of two variables each, so neither form is smaller here. In general the two recipes can give forms of different sizes.
Why we need a better way to find neighbors
Section titled “Why we need a better way to find neighbors”Both examples relied on spotting neighbors in a table, and the table makes that hard. The patterns 001 and 101 are neighbors but sit four lines apart. The patterns 011 and 100 sit on consecutive lines, and they differ in all three inputs. With four inputs a pattern has four neighbors scattered through sixteen rows, and the counting-order layout of the table is no help in finding them.
What we want is a layout of the same truth table in which neighbors are physically next to each other, so that your eye finds the pairs. That layout is the Karnaugh map (Definition 3.5.2), and building one is the next section.
Course conventions
Section titled “Course conventions”How CSE 369 writes this
In CSE 369 we write NOT as an overbar and name the two recipes by their shape: a sum of products from the on set, a product of sums from the off set. Truth table rows are in ascending binary order with the first-listed input as the high bit, which is why 011 comes just before 100. The merging rule is called the uniting theorem.
Pitfalls
Section titled “Pitfalls”Common pitfall
- Taking neighbors in the table to be neighbors in the function. Patterns that sit on consecutive lines may differ in several inputs, and patterns that are far apart may differ in one.
- Building a product from an off-set pattern, or a sum from an on-set pattern. The sum of products reads the ones of the table and the product of sums reads the zeros.
- Putting the bars the wrong way around in a sum. A sum for an off-set pattern shows an input plain where the pattern has 0 and barred where it has 1, the opposite of a product.
- Dropping the wrong variable when merging. Keep every variable that is the same in both patterns and drop only the one that differs.
- Trying to merge two patterns that differ in two or more inputs. Two such patterns cannot be written as a single product, because a product with a variable left out always covers two patterns that differ in that variable.
Check your understanding
Section titled “Check your understanding”Take the quiz (5 questions)
Which expression is the sum of products built from the on set of F, the function in Figure 3.4.1?
The on-set patterns 001 and 101 of F differ only in A. Which term do they merge into?
Which product of sums is built from the off set of F?
The function that is 1 when an odd number of A, B and C are 1 has four patterns in its on set, and none of them is a neighbor of another. How many terms does a minimal sum of products for it have?
Let G be 1 exactly when A and B are equal, whatever C is. On how many of the eight input patterns is G equal to 1?
Exercises
Section titled “Exercises”A function F of three inputs A, B and C is 1 exactly when A and B have the same value, whatever C is. List its on set and its off set, and write the sum of products from the on set.
Hint
Solution
A and B agree when both are 0 or both are 1. With C free, the on set is 000, 001, 110 and 111, and the off set is the other four patterns, 010, 011, 100 and 101.
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Description: A truth table of F with the rows 0 0 0, 0 0 1, 1 1 0 and 1 1 1 highlighted.
One product for each pattern of the on set, with a bar on every input that is 0 in that pattern, gives . The first two products differ only in C, and the last two differ only in C as well, so each pair merges. The merged form is .
Use the uniting theorem to simplify . Say which variable disappears and why.
Hint
Solution
The products match in A and C and differ in B, so B disappears. Factor out what they share, A and C, and the rest is B or its complement, which is always 1.
| Expression | Law used |
|---|---|
| Distributive | |
| Complement | |
| Identity |
List the three neighbors of the input pattern 101 for F, the function in Figure 3.4.1. Which of them are in the on set of F, and what terms do the pairs they form with 101 merge into?
Hint
Solution
Flipping A gives 001, flipping B gives 111, and flipping C gives 100. The patterns 001 and 100 are in the on set, and 111 is not, because F is 0 there. The pair 101 and 001 differs only in A, so A drops out and the term is . The pair 101 and 100 differs only in C, so C drops out and the term is . The pattern 111 is a neighbor of 101, but it is in the off set, so it cannot be merged with an on-set pattern. Merging them would produce a term that is 1 on a pattern where F is 0.
The function in the table below is 0 on the patterns 010, 011 and 110 only. Write a product of sums from its off set, and then merge neighboring off-set patterns to make it smaller.
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
Description: A truth table of F with inputs A, B and C. F is 0 on three rows and 1 on five rows.
Hint
Solution
The three sums are for 010, for 011 and for 110, so the function is .
The patterns 010 and 011 differ only in C, so their sums merge into . The patterns 010 and 110 differ only in A, so their sums merge into . Together these two sums cover all three off-set patterns, so the function is . As a check, the merged form and the original agree: .
Starting from the four products that are 1 on the four patterns with A equal to 1, use the uniting theorem twice to show that they add up to .
Hint
Solution
The products are , , and . The first two differ only in C and the last two differ only in C, so the first round merges them in pairs. The two results differ only in B, so the second round merges them into A.
| Expression | Law used |
|---|---|
| Uniting | |
| Uniting |
Every variable except A was dropped one round at a time, which is why a group of four neighbors on a map has two fewer variables than a single pattern.
Let F be 1 when an odd number of A, B and C are 1, so its on set is 001, 010, 100 and 111. Show that no two on-set patterns are neighbors. What does that tell you about the smallest sum of products for F?
Hint
Solution
Flipping one input changes the number of 1s by exactly one, so it turns an odd count into an even count. Every pattern in the on set has an odd count, so each of its three neighbors has an even count and lies in the off set. No two on-set patterns are neighbors.
A product that leaves out a variable is 1 on two patterns that differ only in that variable. If both were on-set patterns they would be neighbors, so no product of F's smallest form can leave a variable out. Every product keeps all three variables and covers one pattern, and the smallest sum of products has four terms: . The quiz above confirms the count of four with the same function.