5.2 2-Variable K-map: Cell Arrangement, SOP and POS Minimization

Build and read a 2-variable K-map, place 1s from a minterm (Σm) or maxterm (ΠM) specification, and extract the minimized SOP or POS expression by grouping adjacent cells.

The 2-variable K-map is the smallest and simplest Karnaugh map, and it is the ideal place to see the grouping mechanism at full clarity before scaling to 3 or 4 variables. It has exactly four cells, one for each combination of two Boolean inputs A and B, and it can express any 2-input Boolean function — which makes it a perfect tool for verifying, by hand, functions built from a single gate like AND, OR, XOR, NAND, or XNOR, and for building intuition for the wrap-around and grouping rules used in every larger K-map.

Cell arrangement

A 2-variable K-map is a 2×2 grid. One variable (conventionally A) labels the rows and the other (B) labels the columns, each running through Gray-code order 0, 1 — which for a single bit is indistinguishable from binary order, since there is nothing to reorder with only two values. Each of the four cells corresponds to exactly one row of the truth table: (A=0,B=0)=m0, (A=0,B=1)=m1, (A=1,B=0)=m2, (A=1,B=1)=m3.

To build the map from a truth table or a minterm list, place a 1 in every cell whose minterm index appears in the function's minterm sum, and a 0 (or leave blank, depending on convention) in every other cell. Reading the map back out is the reverse process: circle groups of adjacent 1s and write down the corresponding product term for each group.

SOP minimization by grouping 1s

To get the minimized Sum-of-Products (SOP) form, group the 1-cells into the largest possible power-of-two rectangles (using adjacency and wrap-around), mark essential prime implicants first, then cover any remaining 1s with the fewest additional groups. Each group produces one product term: write down only the variables that stay constant across the whole group (uncomplemented if the variable is 1 throughout the group, complemented if it is 0 throughout), and OR all the product terms together.

In the 2-variable case there are only three possible non-trivial group sizes: a single cell (no simplification, keeps both literals), a pair of two adjacent cells (eliminates one variable, leaving a single literal), or all four cells (the constant function 1, eliminating both variables).

POS minimization by grouping 0s

The Product-of-Sums (POS) form is obtained by the same grouping procedure applied to the 0-cells instead of the 1-cells. Group adjacent 0s into the largest valid power-of-two rectangles, and for each group write a sum term containing the variables that stay constant across the group — but with the polarity inverted relative to the SOP rule (a variable that is 0 throughout the group appears uncomplemented in the sum term, and a variable that is 1 throughout appears complemented). Multiply (AND) all the sum terms together to get the minimized POS expression.

SOP and POS minimization are dual procedures over the same map: SOP describes where the function is 1, POS describes where the function is 0 (equivalently, describes the complement of the function and then complements the whole result via De Morgan's laws). Both are valid minimal representations of the same function, and the choice between them is typically driven by which one produces fewer literals, or by which gate types (AND-OR vs OR-AND) are cheaper to implement in the target technology.

2-variable K-map layout

B=0    B=1
A=0   [ m0 ]  [ m1 ]
A=1   [ m2 ]  [ m3 ]

SOP term for a group: AND of literals that stay constant (1 -> variable, 0 -> complemented variable)
POS term for a group:  OR of literals that stay constant (0 -> variable, 1 -> complemented variable)

Code Examples

This is the spec's own worked example: F(A,B) = Σm(1,3). Placing 1s at minterms 1 and 3 shows they occupy the same column (B=1) in different rows, so they form a valid adjacent pair. Only B remains constant across the group, so the entire function collapses to the single literal B — regardless of A's value, F is 1 exactly when B is 1. Expected result: F(A,B) = B

F(A,B) = Σm(1,3) simplifies to F = B, because A is eliminated by the group while B stays constant at 1.

Grouping the two 0-cells shows F is 0 exactly when B=0, i.e., F = B in POS form too — with only one variable left, SOP and POS naturally converge to the same literal here. This cross-check is a good habit: minimizing both the 1s and 0s of a small function and confirming they describe the same truth table builds confidence before scaling to bigger maps where the two forms usually differ.

Grouping 0s instead of 1s gives the complementary view of the same function and is a good self-check.

B=0    B=1
A=0   [  0 ]  [  1 ]   <- m1 = 1
A=1   [  0 ]  [  1 ]   <- m3 = 1

m1 (A=0,B=1) and m3 (A=1,B=1) are vertically adjacent (both have B=1, A differs) -> valid group of 2.
Across the group: B stays 1 (constant) for both cells; A changes (0 -> 1) and is eliminated.

Simplified SOP:  F(A,B) = B
B=0    B=1
A=0   [  0 ]  [  1 ]
A=1   [  0 ]  [  1 ]

0-cells: m0 (A=0,B=0) and m2 (A=1,B=0) — adjacent, B constant at 0, A eliminated.
POS term: since B=0 throughout the group, the sum term is B (uncomplemented, by the POS polarity rule).

Simplified POS: F(A,B) = B   (single sum term, matching the SOP result since there is only one group of 0s)

2-variable K-map minterm layout

Standard 2-variable K-map with Gray-code row (A) and column (B) headings and minterm indices.

B=0    B=1
A=0   [ m0 ]  [ m1 ]
A=1   [ m2 ]  [ m3 ]

Important Rules

Rows and columns are labeled in Gray-code order (trivial for a single bit: just 0, 1).

Place a 1 for every minterm in Σm, and group adjacent 1s for SOP.

Place (conceptually) a 0 for every non-listed cell, and group adjacent 0s for POS.

A group's constant variables become the product/sum term; changing variables are eliminated.

With only 2 variables, the largest possible group (all 4 cells) reduces the function to the constant 1 (SOP) or 0 (POS).

Where 2-input functions show up in real circuits

Two-variable functions are the building blocks of larger digital systems: a 2-input XOR/XNOR pair forms the core of a half adder and half subtractor (covered later in this module), a 2-input AND or OR gate is the base cell replicated across parity trees and wide gates, and 2-input control logic (like a single select bit choosing between two signals) appears constantly in datapaths. Being fluent with the 2-variable K-map means being able to instantly verify, by inspection, that a small piece of glue logic is already in its simplest possible form before it gets synthesized into silicon or an FPGA fabric.

Assuming F(A,B) = Σm(1,3) must include both A and B literals because there are two input variables.

Group the adjacent 1s first and see which variable actually stays constant — here only B does, so F correctly reduces to the single literal B.

The number of input variables to a function is not the number of literals in its minimized form; grouping can eliminate any subset of variables, including all but one.

For F(A,B) = Σm(1,3), which variable is eliminated when grouping the two 1-cells, and why? A. A is eliminated, because A changes value (0 to 1) across the group while B stays constant at 1 B. B is eliminated, because B changes value across the group C. Neither variable is eliminated; the answer keeps both literals D. Both variables are eliminated, leaving the constant function 1

A. A is eliminated, because A changes value (0 to 1) across the group while B stays constant at 1 — m1 = (A=0,B=1) and m3 = (A=1,B=1) differ only in A, so A is the variable that changes and is therefore eliminated by the grouping identity AB + A'B = B, leaving F = B.

In a 2-variable K-map, what does grouping all four cells (m0, m1, m2, m3) together represent? A. The function is the constant 1 for every input combination B. The function is undefined for two of the four combinations C. This grouping is invalid because 4 is not a valid group size D. The function reduces to F = A ⊕ B

A. The function is the constant 1 for every input combination — 4 is a valid power-of-two group size. If all four cells are 1, both A and B are eliminated (since both vary across the group), leaving no literals at all — which represents the constant function F = 1.

Using a 2-variable K-map, minimize F(A,B) = Σm(0,1,2) in SOP form.

m0,m1 (row A=0) form a group where A=0 stays constant, giving term A'. m0,m2 (column B=0) form a group where B=0 stays constant, giving term B'. Together SOP = A' + B'. (Equivalently, since only m3 = A·B is missing, F = (AB)' = A' + B' by De Morgan's law.)

Place 1s at m0, m1, m2 (every cell except m3). Look for the largest valid groups covering all three 1s — you will need two overlapping groups of 2.