Toolvito

Works on this device

Karnaugh Map Solver

Get the Karnaugh map (K-map) of a Boolean function with 2 to 6 variables, the groups of a minimal answer marked in its cells, and the minimal sum of products or product of sums. Don't-care rows are used where they make the answer shorter.

Enter your values

Type the rows where the output is 1, and the rows where it does not matter.

Your values

The names in order, 2 to 6 of them, such as A B C D. The first name is the first (highest) bit of the row number.

Row numbers with commas or spaces. Σm(4, 8, 10) is read too.

Rows where the output does not matter. They join a group only when that makes the answer shorter.

More options

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Calculate.

How to use this solver

  1. Choose how you give the function: minterms (rows where the output is 1), maxterms (rows where it is 0), the output column of a truth table, or an expression.
  2. Type the variable names in order, such as A B C D. The first name is the first (highest) bit of the row number.
  3. Choose to group the 1s for a sum of products, or the 0s for a product of sums.
  4. Choose Calculate. Each cell of the map shows its row number, its value and the letters of the groups that hold it. The list under the map gives each group and its term.

How a Karnaugh map works

  • Each cell is one row of the truth table. The rows and columns are in Gray-code order (00, 01, 11, 10), so cells side by side differ in one variable. The left and right edges, and the top and bottom edges, also count as side by side.
  • Layout: 2 variables: rows A, columns B. 3 variables: rows A, columns BC. 4 variables: rows AB, columns CD. 5 variables: two maps for A = 0 and A = 1, each with rows BC and columns DE. 6 variables: four maps for AB = 00, 01, 11 and 10, each with rows CD and columns EF.
  • A group is a rectangle of 1, 2, 4, 8 or more cells (a power of two) of 1s and don't-cares. With 5 or 6 variables a group may take the same cells in maps that lie next to each other.
  • Each group gives one term: the variables that do not change in it. The fewest and largest groups that hold every 1 give the minimal sum of products. Grouping the 0s in the same way gives the minimal product of sums.
  • The groups are found by the Quine-McCluskey method with Petrick's method, the same as in the Boolean Expression Simplifier, so the two tools give the same answer.

Worked examples

  • Σm(4, 8, 10, 11, 12, 15) + d(9, 14): group a = AB' (cells 8, 9, 10 and 11, with the don't-care 9), group b = AC (cells 10, 11, 14 and 15, with the don't-care 14) and group c = BC'D' (cells 4 and 12). Answer: AB' + AC + BC'D'. AD' could take the place of AB', so there are 2 equally short groupings.
  • A'B'C'D' + A'B'CD' + AB'C'D' + AB'CD' is 1 in the four corner cells 0, 2, 8 and 10. The corners are neighbours across both edges, so they form one group: the answer is B'D'.

Limits you should know

  • 2 to 6 variables. For 7 or 8 variables, use the Boolean Expression Simplifier, which does not draw a map.
  • When several groupings are equally short, the page says how many there are and shows one of them.
  • Minimal means the fewest groups first, then the fewest literals. Forms with XOR or more than two levels of gates are not searched.

Related tools