Tool 04

Karnaugh Map Solver

Fill in a map of 2, 3 or 4 variables with ones, zeros and don't-cares. The tool draws the groups, derives the minimal sum-of-products or product-of-sums expression with every step of the method shown, and builds the two-level gate circuit that implements it.

01

Function

0 ones, 0 don't-cares

Cell numbers read the variables in order, first variable as the most significant bit: with A, B, C, D the cell 6 = 0110 is A'BCD'. Click a cell to cycle it 0, 1, X.

02

Karnaugh map

0 groups
CDAB000111100001111000010302040507060120130150140809011010
  • Constant function, nothing to group.
03

Minimal expression

sum of products
F=0F = 0
Terms0
Literals0
Prime implicants found0
Essential0
Other form (product of sums)0
Show the method, step by step

A Karnaugh map is the truth table folded so that neighbours differ by one variable. Each cell is one minterm, one row of the truth table; its number is the binary value of the variables read in order, so with A, B, C, D the cell numbered 6 is 0110 = A'BCD'. Rows and columns are numbered in Gray code (00, 01, 11, 10), where consecutive codes differ in exactly one bit and the sequence closes on itself: the last column is next to the first, the last row next to the first. So two cells that touch, including across the outer edges, differ in exactly one variable.

That is what makes grouping legal. Two touching ones share every variable but one, and that one takes both of its values inside the pair, so it drops out:

XY+XY=X(Y+Y)=XXY + X\overline{Y} = X\,(Y + \overline{Y}) = X

A rectangle of 4 touching ones repeats the trick twice and drops two variables, 8 drops three, and so on: a group of 2^k cells is one product term of the n - k variables that keep the same value everywhere in it. Bigger groups mean fewer literals, groups may overlap, and they may wrap around the edges. A don't-care cell (X) may be counted as a one or a zero, whichever makes a group bigger, and never has to be covered.

No cell of the map is a one, so there is nothing to group: the function is the constant 0 and needs no gate at all.

F=0F = 0
04

Simplified circuit

0 gates
F = 0

A constant output needs no gate: tie F to ground.

05

Download

A standalone script with this exact function, runnable with node karnaugh-solver.js: prime implicants, essentials, cover, both forms.