Karnaugh Map Solver
Minterms, a truth table or an expression in — minimal SOP and POS out, groups drawn.
Karnaugh map
Click a cell to change it: 0 → 1 → X → 0. Arrow keys move around the map; it wraps at the edges like the map itself.
Prime implicants
| # | Pattern | Term | Covers | Essential |
|---|
How it was solved
Steps for the POS form (the 0 cells)
NAND-only and NOR-only circuits
NAND only
NOR only
Two-level circuits from the minimal SOP (NAND) and POS (NOR), assuming only the plain inputs are available: an inverted input is a gate with its inputs tied together.
Truth table
Click an output to change it. Up and down arrows move between rows.
About the Karnaugh Map Solver
Enter a Boolean function as minterms, maxterms or a typed expression, and the solver draws its Karnaugh map, outlines the groups in colour and gives the minimal sum-of-products (SOP) and product-of-sums (POS) forms. It handles 2 to 6 variables and don’t-care cells.
Under the map it lists every prime implicant and marks the essential ones, explains how the cover was chosen (Quine–McCluskey, then Petrick’s method), and builds the result from NAND gates only and from NOR gates only. The full truth table is editable: click any output, or any map cell, to change it and the answer updates at once.
How to use it
- Choose how to enter the function: Minterms (the cells that are 1), Maxterms (the cells that are 0) or Expression.
- For a list, pick the number of variables and their names — the first name is the most significant bit — then type the numbers, such as
1, 3, 5-7. You can also pasteΣm(1,3,5) + d(0,2). - For an expression, type it with the usual operators, for example
A’B + C(D ⊕ A)or!a && b || c. Put don’t-cares in their own box in any mode. - Read the minimal SOP and POS. When there are several equally small answers, choose one from the list; the map shows its groups. Switch Notation for overbars, C or Verilog operators, or LaTeX.
- Click map cells or truth-table outputs to cycle 0 → 1 → X. Copy result copies the answers, prime implicants and gate lists; Download CSV saves the truth table.
Examples
F(A, B, C, D) = Σm(6, 8, 9, 10, 11, 12, 13, 14)
SOP: AC' + AB' + BCD' · POS: (A + C)(A + B)(B' + C' + D')
F(A, B, C) = Σm(0, 1, 2, 5, 6, 7)
No essential prime implicants. Petrick’s method gives B'C + A'C' + AB or BC' + A'B' + AC (3 terms, 6 literals each)
Σm(1, 3, 7, 11, 15) + d(0, 2, 5)
SOP: CD + A'D (or CD + A'B') · POS: D(A' + C)
A'B + C(D ⊕ A)
Σm(3, 4, 5, 6, 7, 10, 14) → A'B + A'CD + ACD'
How the minimisation works
- Prime implicants (Quine–McCluskey): cells that are 1 or don’t-care and differ in one variable are merged into pairs, then quads and so on; the groups that cannot grow any further are the prime implicants
- Essential prime implicants: a prime implicant that is the only one covering some 1 cell must be in every minimal answer
- Petrick’s method: for the cells still uncovered, the product of sums “one of these prime implicants must be chosen” is multiplied out; the products with the fewest terms, then the fewest literals, are the minimal covers. If that product grows very large, an exhaustive search finds a minimum cover instead
- POS: the same steps on the 0 cells give the minimal SOP of the complement; De Morgan’s law turns each of its products into one sum
Reading the map
Rows and columns are in Gray-code order (00, 01, 11, 10), so neighbouring cells differ in exactly one variable, and the map wraps around: the left edge touches the right edge and the top touches the bottom. A group that wraps is drawn open at the edge. With five variables there are two 4×4 maps (A = 0 and A = 1); with six there are four (AB = 00, 01, 10, 11). Cells in the same position on maps that differ in one variable are adjacent too. Each group has a colour and a number, listed under the map.
Expression syntax
- NOT:
A’,A',!A,~A,¬AorNOT A - AND:
AB,A·B,A*B,A&B,A && BorA AND B - OR:
A + B,A | B,A || B,A ∨ BorA OR B - XOR / XNOR:
A ^ B,A ⊕ B,A XOR B;A ⊙ B,A XNOR B - NAND / NOR:
A ↑ B,A NAND B;A ↓ B,A NOR B(use brackets) - Precedence from strongest: NOT, AND, XOR/XNOR, OR, NAND/NOR. Variables are letters, optionally followed by digits (
x1); letters written together are separate variables, soABis A AND B
NAND-only and NOR-only forms
Any SOP becomes a two-level NAND–NAND circuit: one NAND gate per product term and a NAND gate that combines them. Any POS becomes a NOR–NOR circuit the same way. Inverted inputs are made with a gate whose inputs are tied together. The tool lists every gate and the one-line form, for example F = NAND(NAND(C, D), NAND(NAND(A, A), D)). These two-level circuits come straight from the minimal forms; a multi-level circuit can sometimes use fewer gates.
Sources
- Karnaugh, M. (1953). The map method for synthesis of combinational logic circuits. Transactions of the AIEE, Part I, 72(5), 593–599
- Quine, W. V. (1952). The problem of simplifying truth functions. American Mathematical Monthly, 59(8), 521–531
- McCluskey, E. J. (1956). Minimization of Boolean functions. Bell System Technical Journal, 35(6), 1417–1444
- Petrick, S. R. (1956). A direct determination of the irredundant forms of a Boolean function from the set of prime implicants. AFCRC-TR-56-110, Air Force Cambridge Research Center
Limitations
- Up to 6 variables — beyond that a map is no longer readable. Larger functions need a tool such as Espresso.
- One output at a time: it does not share product terms between several outputs.
- “Minimal” means a two-level form with the fewest terms, then the fewest literals. XOR gates or multi-level logic can sometimes be smaller.
- When Petrick’s product grows too large, the exhaustive search shows one minimal answer even if others of the same size exist.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What is a Karnaugh map?
A grid with one cell per input combination, ordered so that neighbouring cells differ in one variable. Grouping neighbouring 1s in rectangles of 1, 2, 4, 8 … cells shows which variables a term does not depend on, which gives a simpler expression.
What is the difference between SOP and POS?
A sum of products ORs together AND terms, such as AB + C’D, and comes from grouping the 1s. A product of sums ANDs together OR terms, such as (A + B)(C’ + D), and comes from grouping the 0s. Both describe the same function; one is often smaller.
What are don’t-care conditions?
Input combinations whose output does not matter — for example the six unused codes of a BCD digit. Marked X, they may be counted as 1 or 0, whichever gives larger groups. The solver uses them only where they help.
What is an essential prime implicant?
A prime implicant that is the only one covering at least one 1 cell. Every minimal answer must include it. When no prime implicant is essential (a cyclic function), Petrick’s method decides.
Why are there several minimal answers?
Some functions can be covered in more than one way with the same number of terms and literals — Σm(0, 1, 2, 5, 6, 7) has two. All are equally correct; pick one from the list to see its groups.
How is minterm numbering decided?
The first variable is the most significant bit. For F(A, B, C, D), minterm 5 is 0101: A = 0, B = 1, C = 0, D = 1. Rename or reorder the variables to change it.