Karnaugh Map Solver
Enter a Boolean expression or a list of minterms — or click the cells — and the K-map is drawn with its groups circled and the minimal sum of products written out. Two to six variables.
How to use the K-map solver
- Enter the function. Type minterms as
Σm(1, 3, 5, 6, 7)or1,3,5,6,7, or type any Boolean expression such asAB + A'C. - Or click the map. Each cell switches between 0 and 1 when you click it, and the groups are worked out again straight away.
- Read the answer. Every coloured outline is one group of 1s, and each group is one product term of the minimal sum of products shown under the map. The list of groups says which cells each one covers.
How a Karnaugh map simplifies a function
A Karnaugh map, or K-map, is a truth table rearranged into a grid so that neighbouring cells differ in exactly one variable. That is why the row and column labels run 00, 01, 11, 10 — Gray code — rather than in counting order. The left and right edges are neighbours too, and so are the top and bottom, so a group may wrap around the map.
To simplify, circle the 1s in rectangular groups of 1, 2, 4, 8 or 16 cells, making each group as large as possible and using as few groups as will cover every 1. A variable that takes both values inside a group drops out of that group's term; the variables that stay constant remain. A group of two removes one variable, a group of four removes two, and a group of eight removes three.
The largest possible groups are the prime implicants. A prime implicant that is the only one covering some 1 is essential and must be in the answer. The solver finds every prime implicant, keeps the essential ones and then picks the smallest set of the rest that covers what is left.
A worked example
For F = Σm(1, 3, 5, 6, 7) on three variables, the map has two rows (A) and four columns (BC). The 1s in cells 1, 3, 5 and 7 form a block of four in the two middle columns, where C is always 1 while A and B both change: that group is simply C. Cell 6 is left over, and it pairs with cell 7, where A and B are both 1 and C changes: that group is AB.
Two groups cover every 1, so F = AB + C — two gates instead of the five product terms the minterm list started with.
Five and six variables
Four variables is the most that fits in one flat map. For five and six variables the solver draws several four-variable maps side by side, one for each value of the extra variables, and a group may run through the same position on more than one of them.
Questions
How many variables does this K-map solver support?
Two to six. Up to four variables are drawn as one map; five and six are drawn as two or four maps side by side.
Why are the columns labelled 00, 01, 11, 10?
That order is Gray code: each label differs from the next in one bit, so cells that touch on the map differ in one variable. That adjacency is what lets a pair of 1s combine into a simpler term.
Can a group wrap around the edge of the map?
Yes. The left and right columns are adjacent, as are the top and bottom rows, and the four corners form a valid group of four. The solver draws a wrapped group as two or four outlines in the same colour.
Is the answer always the simplest form?
It is a minimal sum of products: no other AND-OR form has fewer product terms. Some functions have more than one minimal answer of the same size, and the solver shows one of them.
Does it handle don't-care conditions?
Not yet. Every cell is either 0 or 1.