Karnaugh Map Solver
Type the rows where your function is 1, or click them on the map, and the page gives back the minimal sum of products with the groups that produced it. The example it opens with, m(0,1,2,5,6,7,8,9,10,14) on four variables, has six prime implicants; the smallest cover of them is CD' + B'C' + A'BD, three groups and seven literals, and no other cover of that size exists. Don't-cares go in their own field and are taken only where they shrink the answer: m(1,3,7,11,15) with d(0,2,5) comes to CD + A'D, two groups and four literals, where the same minterms without the don't-cares need CD + A'B'D. Because a minimal cover is not always the only one, the line under the map names the rivals: that don't-care example also has CD + A'B', exactly the same size, and a page that shows one and hides the other is teaching you something false. Every answer is parsed back and evaluated at all sixteen rows before it appears, so the expression you copy is the function you described.
F = CD' + B'C' + A'BD3 groups, 7 literals, from 6 prime implicants
Checked back against all 16 rows. No other cover of 3 groups and 7 literals exists.
F = CD' + B'C' + A'BD. 3 groups, 7 literals. Checked back against all 16 rows.
Your function
Click a square to walk it through 1, a don't-care and back to 0, or type the row numbers into the two fields: commas, spaces and a pasted m(0,1,2,5) all read the same. Rows are numbered the usual way, with A as the most significant bit, so on a four variable map row 10 is A=1 B=0 C=1 D=0. Every prime implicant is found and the smallest cover is chosen over all of them, which is why the answer can be trusted to be minimal and not merely tidy: on the example this page opens with, that is CD' + B'C' + A'BD, three groups and seven literals out of six prime implicants. Where a cover of the same size exists, the line under the map names it. Your map is kept in this browser so the page opens where you left it, and Start over at the top of the page forgets it.
Common questions
- How are the rows on a Karnaugh map numbered?
- A is the most significant bit, so on a four variable map row 10 is A=1 B=0 C=1 D=0, and on a three variable map, where the variables are A, B and C, row 5 is A=1 B=0 C=1. On a four variable map the rows and the columns both walk in Gray code, 00, 01, 11, 10, so that squares next to each other differ in exactly one variable: that is what makes a block of adjacent squares a single product term. Row 0 sits top left. If your course numbers rows the other way round, with A as the least significant bit, renumber before you type or the groups will be right for a different function.
- Is the expression really the smallest one, or just a tidy one?
- It is the smallest. Every cube of the map is tested, the ones that lie entirely inside your 1s and don't-cares are kept, and the ones no larger cube contains are the prime implicants: the opening example has six of them. The cover is then chosen by exhaustive search over those primes, fewest groups first and then fewest literals, which lands on CD' + B'C' + A'BD, three groups and seven literals. Searching primes loses nothing, because any group that is not prime sits inside one that is and carries more literals, so no smaller answer can hide outside the search.
- What is a don't-care, and when does it actually help?
- A don't-care is a row whose output you do not care about, usually because that input combination cannot occur. It may be absorbed into a group when that makes the group bigger, and ignored when it does not. With m(1,3,7,11,15) and d(0,2,5) the answer is CD + A'D, two groups and four literals; the same minterms with no don't-cares at all need CD + A'B'D, which is a literal longer. A don't-care never turns a 0 into a 1: groups are only ever drawn over 1s and don't-cares, and the finished expression is evaluated at every row of the table to prove that the rows you set to 0 are still 0.
- Why does my textbook give a different answer from this page?
- Because a minimal cover is often not unique, and two different expressions can both be minimal. On m(1,3,7,11,15) with d(0,2,5), CD + A'D and CD + A'B' are both two groups and four literals, so neither is more correct than the other. On the three variable map m(0,1,2,5,6,7), B'C + A'C' + AB and BC' + A'B' + AC tie in the same way. This page shows one and names the other under the map, so you can match whichever your marking scheme used instead of wondering which of you is wrong.
- How many variables does it take, and does it do product of sums?
- Two, three or four variables, and sum of products only. Five and six variable maps need stacked or mirrored grids that stop being readable on a screen, and the honest answer is that the map is the wrong tool at that size. Product of sums is not produced either: you can get it by solving for the zeros of your function and complementing the result by hand, but the page will not pretend to have done that for you. What it does do inside those limits is exact arithmetic, not an estimate.
- What happens if every row is 1, or none of them is?
- Both are answered rather than refused. Sixteen minterms on a four variable map give F = 1: one group covering the whole map and no literals at all, because no variable is needed to describe it. An empty minterm list gives F = 0, no groups and nothing invented to cover it. Don't-cares on their own still give F = 0, since a don't-care is permission rather than an instruction: nothing in the list forces the output to be 1.
- Why will my exclusive-or map not simplify?
- Because it cannot. On the four variable parity map, m(0,3,5,6,9,10,12,15), no two squares that hold a 1 are adjacent, so every group is a single square: eight groups and 32 literals, and that is already the minimum. A solver that returned something shorter would be returning a different function. It is a good map to try when you want to see the difference between an expression that is short and an expression that is minimal.
- Is my map kept, and is anything sent anywhere?
- The solving runs in your browser, there is no account and nothing is uploaded. The variable count, the minterms and the don't-cares are kept in your own browser's storage so the page opens where you left it, and clearing your browser data clears them. Start over at the top of the page forgets them straight away. If your browser blocks storage, the page still works: it simply opens on the example every time.
Every prime implicant is enumerated and the smallest cover is chosen by exhaustive search, so for two to four variables the expression is genuinely minimal rather than merely short. A don't-care is used only where it shrinks the answer and never flips a row you set to zero, and the result is evaluated back against every row of your table before it is shown.