UPI Study › Courses › Discrete Mathematics › Free lessons › Lesson 13.4 Free with a free account
Karnaugh Maps
Discrete Mathematics · Chapter 13: Boolean Algebra and Logic CircuitsSection 13.4 · lesson 84 of 8710 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Discrete Mathematics.
Lesson complete
Earn the 4 college credits for Discrete Mathematics
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: The Arithmetic Logic Unit (ALU) →← Boolean Expressions and Logical OperatorsNext lesson: The Arithmetic Logic Unit (ALU) →
In this lesson
Simplification as visual pattern-matching.
- Explain why K-maps use Gray code order
- Build 2-, 3- and 4-variable maps
- Find prime and essential prime implicants
- Use don't-care cells to shrink expressions
Transcript
Everything said in the video, section by section (1,421 words). Read along, or search it.
Boolean Algebra and Logic Circuits
Karnaugh Maps
This section gives a visual route to simplifying Boolean expressions, the Karnaugh map. Instead of hunting for the next algebraic law, we'll arrange the truth table as a grid and look for rectangles. We'll build maps for two, three and four variables, state the grouping rules precisely, and see how don't-care inputs shrink circuits further.
The Opening Problem
Fewer Gates on a Sensor Board
An embedded-systems engineer is designing the control logic for a small industrial sensor board. The goal is the simplest Boolean expression for each output signal, because every extra gate on the chip costs silicon area, power and propagation delay. The algebraic route works, but it requires spotting which law applies next, amid a page of symbols. The Karnaugh map, or K-map, takes a different route. It's a grid that turns simplification into a visual pattern-matching task. Nothing about the laws changes. The K-map just reaches equivalent results another way.
13.4.1
Why Gray Code Order
A K-map gives every minterm its own cell. And it arranges the grid so that any two cells sharing an edge differ in exactly one variable. That property isn't automatic. It has to be built into how the rows and columns are labeled. Try ordinary counting order: zero zero, zero one, one zero, one one. The middle step, zero one to one zero, flips two bits at once. So neighboring cells would differ in two variables. Reorder them as zero zero, zero one, one one, one zero. Now every step flips exactly one bit. And since the sequence is used cyclically, even the wraparound from one zero back to zero zero flips just one bit. That ordering is called a Gray code. So a Karnaugh map is a grid with one cell per minterm, holding the function's value, with its rows and columns labeled in Gray code order.
Figure 1
A 2-Variable Map
With two variables, one labels the rows and the other the columns. Each has only two values, so the adjacency property holds automatically. Let F of A and B have minterms zero, one and three. So F is one everywhere except at A equals one, B equals zero. The top row, A equals zero, is all ones. Across that row, B takes both values, and only A equals zero stays fixed. So it gives the term A prime. The right column, B equals one, is also all ones. Only B equals one stays fixed there, giving the term B. Together, F equals A prime plus B. We got there without applying a single named law, just by reading what stays fixed across each block.
13.4.2
A 3-Variable Map: Go Big
With three variables, A labels the two rows, and B C labels four columns, in the Gray order zero zero, zero one, one one, one zero. Let F have minterms zero, one, two, three, five and seven. The top row is entirely ones, giving the term A prime and covering minterms zero through three. That leaves minterms five and seven. You could group them as an isolated pair. But that misses something bigger. The columns zero one and one one are all ones in both rows. That's a group of four, where A and B both vary, and only C stays fixed at one. So that group gives the single-literal term C, and F equals A prime plus C. That's the central rule. Always look for the largest valid rectangle before settling for a smaller one, because a bigger group always gives a shorter term.
Four Variables
Wraparound in Both Directions
With four variables, A B labels four rows and C D labels four columns, both in Gray code order. That's a four by four grid of sixteen cells. Wraparound adjacency now works in both directions. The leftmost and rightmost columns are adjacent, and so are the top and bottom rows. So all four corner cells are mutually adjacent. Each pair of corners differs in exactly one variable, through one of the two wraparounds. Here's an example with ten minterms: zero, two, and eight through fifteen.
Figure 3
Reading a 4-Variable Map
Here's the map. The bottom two rows, A B equals one one and one zero, are entirely ones. In both rows, A is one, and B varies. That's a group of eight, giving the single term A. That leaves minterms zero and two, both in the top row, still uncovered. They're corner cells. And the bottom row supplies the two other corners. All four corners are mutually adjacent by wraparound. All four share B equals zero and D equals zero, with A and C free. So they give the term B prime D prime. So F equals A plus B prime D prime. And that corner group is essential, because nothing else covers minterms zero and two.
13.4.3
Valid Groups and Prime Implicants
Now the grouping rule, stated precisely. A valid group is a rectangular block of cells, wraparound allowed, where every cell contains a one, or a don't-care being used as a one. Its size must be a power of two: one, two, four, eight or sixteen. And it must be as large as possible, not contained inside some larger valid block. A group meeting all three conditions is called a prime implicant. And if some one-cell is covered by only one prime implicant, that implicant is essential. It must appear in every minimal sum-of-products expression.
Table 1
Bigger Groups, Shorter Terms
Here's why bigger is better. In a group of two to the k cells, exactly k variables take both values somewhere in the group, so they drop out of the term. The other variables stay fixed throughout, so they survive in the term. A single cell eliminates nothing. A pair eliminates one variable, a group of four eliminates two, eight eliminates three, and sixteen eliminates four. It's the same principle the algebraic combining law captures with symbols. The K-map just lets you read it off the grid. And both worked examples had only essential prime implicants. In the three-variable map, minterm zero needs A prime, and minterm five needs C. In the four-variable map, minterms nine, eleven, thirteen and fifteen need A, and minterms zero and two need B prime D prime.
13.4.4
Don't-Care Conditions
Some input combinations never arise in practice, or don't affect what the circuit has to do. These are don't-care conditions, marked X on the map. When grouping, an X can be treated as zero or one, whichever allows a bigger group. And it never has to be covered. Here's an example. A binary-coded decimal digit uses four bits, W, X, Y and Z. But only the values zero through nine ever occur. So the six codes from ten to fifteen never appear. They're don't-cares. Suppose the output F must be one exactly when the digit is five through nine. That gives this map, with the X cells in the third row, and in the right half of the bottom row.
Figure 4
Using the Don't-Cares
Without the don't-cares, treating codes ten to fifteen as zero, the biggest groups are pairs. That gives W prime X Y, plus W prime X Z, plus W X prime Y prime. Three terms, and nine literals in total. Now use the don't-cares favorably. Treating fourteen and fifteen as one extends the pair six, seven into a group of four, giving just X Y. Treating thirteen and fifteen as one turns the pair five, seven into X Z. And treating ten and eleven as one turns eight, nine into W X prime. So F equals X Y plus X Z plus W X prime. Still three terms, but only six literals. Every required one, five through nine, is covered, and no code from zero to four is ever set to one. The saving comes purely from choosing among the don't-cares. Don't-cares like these are common wherever the surrounding system restricts the inputs: display decoders, impossible sensor combinations, and unused states in state machines.
Takeaways
Find the Biggest Rectangles
To summarize. A Karnaugh map puts one truth-table row in each cell, with Gray code labels, so that adjacent cells, including wraparound pairs, differ in exactly one variable. Two-variable maps are two by two, three-variable maps two by four, and four-variable maps four by four, where even the four corners are adjacent. A prime implicant is a maximal, power-of-two rectangle of ones. An essential one is the only cover for some cell, and must appear in the minimal expression. Bigger groups eliminate more variables. And don't-cares, used favorably, can shrink the result, like the drop from nine literals to six. Here's something to think about. A five-variable function has thirty-two cells, and a six-variable function has sixty-four. As the grid grows, does looking for the biggest rectangle by eye still guarantee a truly minimal expression? Or does it depend on the map staying small enough to check every grouping?
About Discrete Mathematics at UPI Study
Discrete Mathematics (Math 230) is a self-paced online course of 87 video lessons in 13 chapters, from logic and proof to counting, probability, graph theory and trees. It carries a NCCRS credit recommendation for 4 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take Discrete Mathematics with UPI Study
Where the credit goes
Universities that work with NCCRS
Discrete Mathematics carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Karnaugh Maps
Why do Karnaugh maps label rows and columns in Gray code order?
How do you find prime and essential prime implicants on a K-map?
How do you read a product term from a group on a 4-variable K-map?
How do don't-care cells make a K-map expression simpler?
About the Discrete Mathematics course
How many college credits is Discrete Mathematics?
How much does Discrete Mathematics cost and what is included?
Which universities accept UPI Study credits?
How long does Discrete Mathematics take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 4 credits in Discrete Mathematics.
87 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
4 credits · NCCRSEnroll →