Skip to content
KmapGen

2-Variable K-Map

The smallest Karnaugh map: 4 cells for the variables A and B. Solve your own map below, then see how the layout and grouping work.

Variables
2-variable Karnaugh map (click cells to edit)AB010110110213

Click or tap a cell to change it. Keyboard: Tab to the map, arrows move, Enter or Space cycles, 0 / 1 / X set the value. Small numbers are minterm numbers.

Minimal SOP (sum of products)

F = A' + B

2 product terms, 2 literals
Unique minimal answer.

Minimal POS (product of sums)

F = A' + B

1 sum term, 2 literals
Unique minimal answer.

Step-by-step solution

1. Groups on the map (SOP)

The 1s are covered by 2 groups. In each product term, a variable that stays 1 across the group appears as is and one that stays 0 appears complemented. Hover or tap a term to highlight its group.

  • A' group of 2 · cells 0, 1 · pattern 0– essential

    A = 0 in every cell; B changes inside the group and drops out. It is essential: m0 is covered by no other prime implicant.

  • B group of 2 · cells 1, 3 · pattern –1 essential

    B = 1 in every cell; A changes inside the group and drops out. It is essential: m3 is covered by no other prime implicant.

2. Prime implicants and essential primes

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.

PrimeTermPatternm0m1m3
P1 *A'0–⊗×
P2 *B–1×⊗

Essential: P1, P2. The essential primes cover everything.

3. Petrick's method: choosing the cheapest cover

Not needed: the essential prime implicants already cover every required cell, so the answer is unique.

4. Quine–McCluskey tabulation

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

1sCellsPattern
0000✓
1101✓
2311✓

Groups of 2

1sCellsPattern
00,10–PI
11,3–1PI
5. Truth table, Σm, ΠM and canonical forms
#ABF
0001
1011
2100
3111

Minterm list: F = Σm(0, 1, 3)

Maxterm list: F = ΠM(2)

Canonical SOP (one term per 1): A'B' + A'B + AB

Canonical POS (one clause per 0): A' + B

Row number = minterm number, with A as the most significant bit.

6. Logic circuit (AND–OR)

Two-level AND–OR realization: one AND gate per term (a single-literal term is wired straight through), then one OR gate. 2 gates including inverters, 2 gate inputs. Replacing every AND and the final OR with NAND gates gives the equivalent NAND–NAND circuit with the same wiring (single-literal terms then need their complement).

AA′BF

Layout and cell numbers

Rows are labeled by A (0, 1) and columns by B (0, 1). The number in each cell is the minterm number, the decimal value of AB read as a binary number.

2-variable K-map: minterm numbers
A \ B 01
0 m0m1
1 m2m3

Worked example: F = Σm(1, 2, 3)

Three cells are 1: m1 (A′B), m2 (AB′) and m3 (AB). The bottom row (A = 1) is a pair, and the right column (B = 1) is a pair. Both groups share m3, which is allowed.

Solved 2-variable K-map for Σm(1, 2, 3)AB010100111213
F = Σm(1, 2, 3) → F = A + B
  1. A: group of 2 (m2, m3), essential. A = 1 in every cell; B changes inside the group and drops out.
  2. B: group of 2 (m1, m3), essential. B = 1 in every cell; A changes inside the group and drops out.

Result: F = A + B, 2 terms and 2 literals. Open this example in the solver.

Algebraically: A′B + AB′ + AB = A(B′ + B) + B(A′ + A) = A + B, using AB twice (X = X + X).

All 16 two-variable functions

There are 24 = 16 possible functions of two variables, and every one of them has a minimal SOP of at most two terms: 0, 1, A, B, A′, B′, AB, AB′, A′B, A′B′, A + B, A + B′, A′ + B, A′ + B′, and the two that do not simplify at all, AB′ + A′B (XOR) and AB + A′B′ (XNOR), whose 1s sit on a diagonal.

Frequently asked questions

How many cells does a 2-variable K-map have?

Four, one for each combination of A and B: m0 (A = 0, B = 0), m1 (0, 1), m2 (1, 0) and m3 (1, 1). They are arranged in a 2×2 grid with A on the rows and B on the columns.

What groups are possible in a 2-variable K-map?

A single cell (2 literals, e.g. AB′), a pair in a row or column (1 literal: A, A′, B or B′), or all four cells (the constant 1). There are no diagonal groups: m0 and m3 differ in both variables.

Is a 2-variable K-map worth using?

It is mostly a teaching step: with two variables you can usually see the answer from the truth table. It shows the key idea in the smallest form: two neighboring 1s merge and the variable that changes disappears.