Karnaugh map solver
A Karnaugh map solver simplifies a Boolean expression by laying its truth table out as a grid and grouping neighbouring 1s. Each group of 1, 2, 4 or 8 cells becomes one simple term, and together the groups give the minimal sum of products. Our Boolean Algebra Simplifier draws the Karnaugh map (K-map) for up to 4 variables, outlines the groups it uses, and gives the minimal sum of products or product of sums.
The K-map sits under the simplified answer, so there is no separate mode to switch to: type an expression and the map appears. It opens on A'B + AB + AB', whose map simplifies to A + B.
Boolean Algebra Simplifier
Simplify expressions with Boolean laws and Karnaugh maps
How to use the Karnaugh map solver
- Type the expression in the Expression box, such as A'B'C' + A'BC' + AB'C + ABC. Use ' or NOT for "not", letters side by side or AND for "and", and + or OR for "or".
- Choose Group the 1s for the minimal sum of products, or Group the 0s for the minimal product of sums.
- Read the K-map, with each group outlined, and the minimal form beside it.
- Tap a cell to mark it as a don't care (X). The minimal form uses it only if that makes the answer smaller.
- Follow the working, which also simplifies the expression one law at a time, naming each law.
Maps go up to 4 variables. For 5 to 8 variables the calculator still finds the minimal form, by the Quine-McCluskey method, but does not draw a map. You can change how answers are written, as AND OR, as ∧ ∨ ¬, or as · + ′.
From minterms to the solver
Many K-map questions give the minterms, such as F(A, B, C) = Σm(0, 2, 5, 7). The calculator takes an expression, not a minterm list, so write each minterm as a product: write the number in binary, then use a letter for each 1 and a NOT letter for each 0.
| Minterm | Binary ABC | Product term |
|---|---|---|
| m0 | 000 | A'B'C' |
| m2 | 010 | A'BC' |
| m5 | 101 | AB'C |
| m7 | 111 | ABC |
So Σm(0, 2, 5, 7) is A'B'C' + A'BC' + AB'C + ABC. Type that, and the calculator draws the map with those four 1s.
How to solve a Karnaugh map by hand
- Draw the grid with its rows and columns in Gray code order, 00, 01, 11, 10, so neighbouring cells differ by one variable.
- Put a 1 in each cell where the function is 1.
- Group the 1s in rectangles of 1, 2, 4, 8 or 16 cells. Make each group as big as possible, and use as few groups as you can. Groups may overlap and wrap round the edges.
- For each group, keep the variables that stay the same across it and drop the ones that change.
- Add up (OR) the terms from all the groups.
Worked examples you can check in the calculator
Example 1: three variables
Simplify F = Σm(0, 2, 5, 7). The 1s at m0 and m2 are neighbours, where A = 0 and C = 0, giving A'C'. The 1s at m5 and m7 are neighbours, where A = 1 and C = 1, giving AC:
Type A'B'C' + A'BC' + AB'C + ABC and the calculator gives A·C + A′·C′, down from 12 letters to 4. Choose Group the 0s and it gives the product of sums (A′ + C)(A + C′).
Example 2: four variables, with wrap-around
Simplify F(A, B, C, D) = Σm(0, 1, 2, 5, 8, 9, 10). The map, with AB down the side and CD across the top:
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 1 | 1 | 0 | 1 |
| 01 | 0 | 1 | 0 | 0 |
| 11 | 0 | 0 | 0 | 0 |
| 10 | 1 | 1 | 0 | 1 |
- The four cells for C′D′ and C′D in rows 00 and 10 make a group of 4, where B = 0 and C = 0: B′C′.
- The four corners are neighbours, because the map wraps round: B = 0 and D = 0, so B′D′.
- m1 and m5 make a pair, where A = 0, C = 0 and D = 1: A′C′D.
Write the seven minterms as products and the calculator gives the same three terms, down from 28 letters to 6.
Example 3: don't cares
F = Σm(1, 3, 7, 11, 15), with don't cares at m0, m2 and m5. Without the don't cares, the best is A′B′D + CD. Tap cells 0, 2 and 5 on the map to mark them X, and the calculator can now make a group of four in the top row, giving A′B′ + CD, one letter shorter.
Check yourself:
What the solver does not do
- No minterm list input. Type the expression, or write each minterm as a product first, as above.
- You cannot fill cells with 1s. Tapping a cell only marks a don't care. The 1s come from the expression.
- Maps stop at 4 variables. It still simplifies up to 8 variables, but without drawing a map.
Common mistakes
- Using binary order instead of Gray code. Columns must go 00, 01, 11, 10, or neighbouring cells will not differ by one variable.
- Making groups of 3 or 6. Groups must be 1, 2, 4, 8 or 16 cells, in rectangles.
- Missing the wrap-around. The left and right edges are neighbours, and so are the top and bottom. The four corners can form one group.
- Groups that are too small. A bigger group gives a shorter term. Always look for the largest groups first.
- Treating don't cares as 1s you must cover. Use them only if they make a group bigger.
Practise logic in a short timed paper
Boolean logic and logic gates come up in AP Computer Science Principles practice, and in GCSE Computer Science in the UK. Each daily paper is a short timed paper of 8 questions worth 25 to 35 marks, and the papers mix topics. Our Boolean algebra calculator guide covers simplifying with the laws, and the Circuits course covers truth tables and gates.
Common questions
What is a Karnaugh map?
How do you solve a 4-variable K-map?
What are don't care conditions?
What is the difference between sum of products and product of sums?
Why is Gray code used on a K-map?
Can the solver handle 5 variables?
Revision cards
Say the answer first, then flip the card to check it.
Where to go next
- Solve it
Boolean Algebra Simplifier
Simplify expressions with Boolean laws and Karnaugh maps
Open the tool - Learn it
Circuits
Resistors, capacitors and logic gates: build and understand real circuits
Start the course - Test it
AP Computer Science Principles
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper