The Quine–McCluskey Method, Step by Step
Updated 2026-11-22 · 8 min read
Quine–McCluskey is the classic exact method for two-level logic minimization, and the one the K-map solver on this site runs. It has two phases: find all prime implicants, then pick the cheapest set of them that covers the function.
Running example: F(A, B, C, D) = Σm(0, 1, 2, 5, 6, 7, 8, 9, 10, 14).
Phase 1: find the prime implicants
- Write each minterm and each don’t-care in binary and sort them into groups by their number of 1 bits. Don’t-cares take part in combining so that groups can grow, but in phase 2 they get no column: they never need to be covered.
- Compare every term in group k with every term in group k + 1. If two terms differ in exactly one bit, combine them, writing a dash in that position, and check both off.
- Repeat with the new column (terms with one dash, then two dashes…). Only terms with dashes in the same positions can combine.
- When nothing combines any more, every term that was never checked off is a prime implicant.
Cells are sorted by their number of 1 bits. Two entries in neighboring groups combine when their patterns differ in exactly one position (that position becomes –). ✓ = combined further; PI = could not be combined, so it is a prime implicant.
Groups of 1
| 1s | Cells | Pattern | |
|---|---|---|---|
| 0 | 0 | 0000 | ✓ |
| 1 | 1 | 0001 | ✓ |
| 2 | 0010 | ✓ | |
| 8 | 1000 | ✓ | |
| 2 | 5 | 0101 | ✓ |
| 6 | 0110 | ✓ | |
| 9 | 1001 | ✓ | |
| 10 | 1010 | ✓ | |
| 3 | 7 | 0111 | ✓ |
| 14 | 1110 | ✓ |
Groups of 2
| 1s | Cells | Pattern | |
|---|---|---|---|
| 0 | 0,1 | 000– | ✓ |
| 0,2 | 00–0 | ✓ | |
| 0,8 | –000 | ✓ | |
| 1 | 1,5 | 0–01 | PI |
| 1,9 | –001 | ✓ | |
| 2,6 | 0–10 | ✓ | |
| 2,10 | –010 | ✓ | |
| 8,9 | 100– | ✓ | |
| 8,10 | 10–0 | ✓ | |
| 2 | 5,7 | 01–1 | PI |
| 6,7 | 011– | PI | |
| 6,14 | –110 | ✓ | |
| 10,14 | 1–10 | ✓ |
Groups of 4
| 1s | Cells | Pattern | |
|---|---|---|---|
| 0 | 0,1,8,9 | –00– | PI |
| 0,2,8,10 | –0–0 | PI | |
| 1 | 2,6,10,14 | ––10 | PI |
Phase 2: the prime implicant chart
Draw one row per prime implicant and one column per minterm (don’t-cares get no column), and mark which primes cover which minterms. A column with a single mark identifies an essential prime implicant.
Each row is a prime implicant (a group that cannot be made larger). A ⊗ marks a minterm covered by a single prime: that prime is essential (*) and must be in every minimal answer.
| Prime | Term | Pattern | m0 | m1 | m2 | m5 | m6 | m7 | m8 | m9 | m10 | m14 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| P1 * | B'C' | –00– | × | × | × | ⊗ | ||||||
| P2 | B'D' | –0–0 | × | × | × | × | ||||||
| P3 * | CD' | ––10 | × | × | × | ⊗ | ||||||
| P4 | A'C'D | 0–01 | × | × | ||||||||
| P5 | A'BD | 01–1 | × | × | ||||||||
| P6 | A'BC | 011– | × | × |
Essential: P1, P3. Still uncovered after the essentials: m5, m7.
Remove the essential primes and every minterm they cover. Whatever remains is solved with Petrick’s method:
Every uncovered minterm needs at least one of the primes that cover it. Petrick's method writes that as a product of sums and looks for its cheapest products:
P = (P4 + P5)(P5 + P6)
Cheapest choices (fewest terms, then fewest literals): P5. Each choice plus the essential primes is one minimal answer.
The result, drawn on a K-map:
- A'BD: group of 2 (m5, m7). A = 0, B = 1, D = 1 in every cell; C changes inside the group and drops out.
- B'C': group of 4 (m0, m1, m8, m9), wrapping top–bottom edges, essential. B = 0, C = 0 in every cell; A, D change inside the group and drop out.
- CD': group of 4 (m2, m6, m10, m14), essential. C = 1, D = 0 in every cell; A, B change inside the group and drop out.
Result: F = A'BD + B'C' + CD', 3 terms and 7 literals. Open this example in the solver.
Petrick’s method on a cyclic chart
When no prime is essential, the chart is cyclic and there is no obvious first choice. Petrick’s method writes the covering condition as a product of sums and expands it. For F(A, B, C) = Σm(0, 1, 2, 5, 6, 7):
Each row is a prime implicant (a group that cannot be made larger). A ⊗ marks a minterm covered by a single prime: that prime is essential (*) and must be in every minimal answer.
| Prime | Term | Pattern | m0 | m1 | m2 | m5 | m6 | m7 |
|---|---|---|---|---|---|---|---|---|
| P1 | A'B' | 00– | × | × | ||||
| P2 | A'C' | 0–0 | × | × | ||||
| P3 | B'C | –01 | × | × | ||||
| P4 | BC' | –10 | × | × | ||||
| P5 | AC | 1–1 | × | × | ||||
| P6 | AB | 11– | × | × |
No prime implicant is essential (a cyclic chart). Still uncovered after the essentials: m0, m1, m2, m5, m6, m7.
Every uncovered minterm needs at least one of the primes that cover it. Petrick's method writes that as a product of sums and looks for its cheapest products:
P = (P1 + P2)(P1 + P3)(P2 + P4)(P3 + P5)(P4 + P6)(P5 + P6)
Cheapest choices (fewest terms, then fewest literals): P5·P1·P4, P6·P2·P3. Each choice plus the essential primes is one minimal answer.
Expanding by hand quickly gets long (here 26 = 64 raw products before simplification). Programs avoid the full expansion with a branch-and-bound search that only keeps products that can still tie for the minimum; this site does that and returns every minimum, not just one.
Complexity and practical limits
A function of n variables can have on the order of 3n/n prime implicants, and choosing the cheapest cover is NP-hard. For the sizes students meet (up to 6–8 variables) an exact answer takes milliseconds. Industrial tools such as Espresso use heuristics for hundreds of inputs and accept answers that are near-minimal.
Frequently asked questions
What is the Quine–McCluskey method?
A tabular algorithm for minimizing Boolean functions, developed by Willard Quine (1952) and Edward McCluskey (1956). It finds every prime implicant by repeatedly combining terms that differ in one bit, then selects a minimum set of primes that covers all minterms. It gives the same result as a K-map but works for any number of variables and is easy to program.
What is the difference between a K-map and Quine–McCluskey?
They compute the same thing. A K-map finds prime implicants visually, which is fast up to 4 variables and awkward beyond 6. Quine–McCluskey finds them by systematic comparison, which is tedious by hand but works for any size and never misses a group.
What is Petrick's method?
A way to choose the cheapest cover when the prime implicant chart has no essential primes left (a cyclic chart). Each remaining minterm becomes a sum of the primes that cover it; multiplying these sums out gives every possible cover, and the products with the fewest primes (then fewest literals) are the minimal solutions.
What is an essential prime implicant?
A prime implicant that is the only one covering some minterm. It must be in every minimal solution. In the chart, it is the row containing the only mark in some column.
Sources
- W. V. Quine, “The Problem of Simplifying Truth Functions,” The American Mathematical Monthly, 59(8):521–531, 1952.
- E. J. McCluskey, “Minimization of Boolean Functions,” Bell System Technical Journal, 35(6):1417–1444, 1956.
- S. R. Petrick, “A Direct Determination of the Irredundant Forms of a Boolean Function from the Set of Prime Implicants,” Air Force Cambridge Research Center, Technical Report AFCRC-TR-56-110, 1956.
Related tools and guides
- K-map solver Free K-map solver for 2 to 6 variables: enter cells, minterms, a truth table or an expression, add don't-cares, and get every minimal SOP and POS with steps.
- How to solve a K-map How to solve a Karnaugh map in 6 steps, with worked 3- and 4-variable examples, a cyclic map with two answers, and the mistakes that cost marks.
- Boolean simplifier Simplify a Boolean expression step by step: De Morgan, distributive, absorption, consensus and more, ending on a proven minimal SOP, plus the minimal POS.
- 5-variable K-map Solve a 5-variable Karnaugh map. How the two 4×4 maps (A = 0, A = 1) work, which cells are adjacent across them, and a worked example with steps.