Layouts of a 4-Input K-Map
In a 4‑input Karnaugh map, two variables are typically assigned to the rows and the other two to the columns, resulting in a standard \(\mathsf{4\times{}4}\) grid of 16 cells. While alternative layouts such as \(\mathsf{2\times{}8}\) or \(\mathsf{8\times{}2}\) are technically valid, the \(\mathsf{4\times{}4}\) format is the most intuitive and widely adopted due to its symmetry and ease of visualization. For this reason, we recommend readers use the \(\mathsf{4\times{}4}\) layout when solving 4‑variable K‑maps.
To illustrate layout equivalence, we’ll briefly explore the \(\mathsf{2\times{}8}\) form in the Frequently Asked Questions section and explain why it may not be ideal for all scenarios.
As with 2‑ and 3‑input K‑maps, Gray codes are used to label both axes, ensuring that adjacent cells differ by only one bit. This structured labeling is essential for identifying valid groupings during simplification, with each cell representing a unique combination of input variables.
Alternative Labeling
In some K-map layouts, the row and column labels are presented not as Gray codes, but directly as complemented and uncomplemented variables. However, Gray code ordering still governs the cell arrangement to preserve adjacency. These variable-based labels may offer a more intuitive bridge between the map and the original Boolean function, and may appeal more to some readers. A 4-variable K-map with alternative labels and input combinations, is shown here:
Minterms in a 4-Variable K-map
In the figure below, each cell is annotated with its corresponding minterm, determined by the input combination specified by the variables’ row and column labels,.
Adjacency Discussion
In a 4‑input Karnaugh map arranged as a \(\mathsf{4\times{}4}\) grid, two variables are assigned to the rows and two to the columns, with Gray codes labeling both axes. This ensures that adjacent cells differ by only one bit, allowing valid groupings for simplification.
Just like in 2‑ and 3‑input K‑maps, the edges of the \(\mathsf{4\times{}4}\) map wrap around — meaning cells on opposite sides are considered adjacent. For example, the leftmost and rightmost columns, as well as the top and bottom rows, are adjacent under Gray code logic. This wrap‑around adjacency allows for forming larger groups such as:
- Pairs
- Quads
- Octets
These groupings are valid as long as the cells differ by only one variable and the group size is a power of two (1, 2, 4, 8, or 16). Corner cells can participate in edge‑wrapping quads, and seemingly distant 1s may be grouped together due to this adjacency.
In diagrams, highlighting the top and bottom edges in green and the left and right edges in orange — along with double‑headed arrows — effectively communicates this wrap‑around behavior. This visual cue helps clarify that 1s on opposite edges can be grouped into larger implicants, even when they appear disconnected in the flat layout.
Example 1: Construct a K-map
Construct a K-map for the function \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\)
Example 2: Construct a K-map
Construct a K-map for the function \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\). \(\mathsf{m_8}\) is a Don’t Care, \(\mathsf{X}\).
How to Solve a K-map?
This section outlines the general procedure for solving a K‑map, illustrated first with a simple 2‑input example. Starting with this basic case ensures that anyone can grasp the core concepts, regardless of which page they begin on. More complex examples—matching the number of inputs featured on the page—are introduced afterwards. To explore specific cases in detail, select the relevant page for 2‑, 3‑, 4‑, or 5‑input K‑maps. For an overall introduction to K‑maps, Gray codes, and minterms ordering, refer to their dedicated pages or sections.
The following steps are followed while solving a K-map.
- Identify Implicants: Identify groups of adjacent 1s that can be grouped in powers of 2 (1, 2, 4, 8, …).
- Make Prime Implicants: Form largest possible groups that collectively include all the relevant minterms.
- Determine the Product Term: For each group, determine the variable(s) that remain constant across it.
- Write Minimum Cost Solution: Combine terms using OR to generate the solution in SOP form.
In more precise terms, the process of grouping the largest possible sets of minterms in powers of two is essentially the search for prime implicants among all possible implicants. The resulting Sum of Products (SOP) expression is considered to be in its simplest form when it achieves the minimum cost—typically measured in terms of the fewest possible literals or logic gates required for implementation.
Step 1: Identify Implicants
An implicant is simply a product term that describes one or more specific input combinations where the function’s output is 1. The simplest implicants are the individual minterms. However, implicants aren’t limited to single minterms — by combining adjacent implicants in groups whose sizes are powers of two, we can form larger implicants that cover more minterms while still remaining valid.
We will explain the process with the help of a \(\mathsf{2\times{}2}\) 2-inputk-map for ease. Consider the following K‑map:
It contains a total of five implicants as highlighted in the figure. Of these, three are individual minterms, while the other two arise from grouping pairs of adjacent 1’s, \(\mathsf{m_0,m_2}\) and \(\mathsf{m_2,m_3}\), each forming a valid implicant.
Step 2: Make Prime Implicants
A prime implicant is an implicant that cannot be combined with any other implicant to form a larger valid group. In a K‑map, it represents the largest possible block of 1’s that contains no 0’s. It may or may not cover all the 1’s in the map, and in most cases, multiple prime implicants exist. In the above example, the two implicants which are formed by the groupings of \(\mathsf{m_0\textsf{ & }m_2}\), and \(\mathsf{m_2\textsf{ & }m_3}\), are the prime implicants.
Step 3: Determine the Product Term for Each Prime Implicant
To determine the product term for each prime implicant, identify the variables that remain constant across all 1’s in that group. Iteratively check each variable, and drop any literal that changes within the grouping. The remaining literals — whether in complemented or uncomplemented form — represent the constant variables for that largest valid block.
In the example, for the first prime implicant, covering minterms \(\mathsf{m_0}\) and \(\mathsf{m_2}\), input B is fixed at 0 across both minterms, while A changes from 0 in \(\mathsf{m_0}\) to 1 in \(\mathsf{m_2}\). Since A varies, it is dropped. The constant B = 0 corresponds to the literal \(\mathsf{B’}\).
For the second prime implicant, covering minterms \(\mathsf{m_2}\) and \(\mathsf{m_3}\), A remains fixed at 1 in both cases, while B changes. Thus, A = 1 is retained, giving the product term \(\mathsf{A}\).
Step 4: Write Minimum Cost Solution
Once all essential prime implicants have been selected, the final Boolean expression is obtained by combining their corresponding product terms using the OR operator (\(\mathsf{+}\)). If there are remaining prime implicants that can be included in multiple ways at equal minimal cost, any such combination may be chosen, as all yield functionally equivalent minimal solutions. The simplest function is:
\[\mathsf{Z=A+B’}\]
Example 3: Express in the simplest form \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:
\[\mathsf{Z=A’B’D’}\]
This is obtained by joining the minterms \(\mathsf{m_0}\) and \(\mathsf{m_2}\) around the edge as shown in the picture.
Example 4: Express in the simplest form \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2,8\right)}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. There are two grouping that can be done here, combining \(\mathsf{m_0}\) and \(\mathsf{m_2}\) along horizontal edges, and \(\mathsf{m_0}\) and \(\mathsf{m_8}\) along vertical edges. By joining these prime implicants, we get the simplest function:
\[\mathsf{Z=A’B’D’+B’C’D’}\]
The solution is graphically presented for better understanding.
Example 5: Express in the simplest form \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\) with \(\mathsf{X}\) at \(\mathsf{m_8}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:
\[\mathsf{Z=A’B’D’}\]
Using \(\mathsf{X}\) as 0 helped us keep the cost to minimum. Treating it as 1 would have added a term with 3 literals. This increases the cost by 7 as 2 gates (1 AND and 1 OR) with 3 and 2 inputs respectively would be added. The solution is graphically presented for better understanding.
Example 6: Express in the simplest form \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,\right.}\)\(\mathsf{\left.2,\right.}\)\(\mathsf{\left.5,\right.}\)\(\mathsf{\left.6,\right.}\)\(\mathsf{\left.7,\right.}\)\(\mathsf{\left.8,\right.}\)\(\mathsf{\left.10,\right.}\)\(\mathsf{\left.13,\right.}\)\(\mathsf{\left.14,\right.}\)\(\mathsf{\left.15\right)}\)
The four corner minterms — \(\mathsf{m_0, m_2, m_8,}\) and \(\mathsf{m_{10}}\) — wrap around the horizontal and vertical edges to form a valid quad, yielding the prime implicant \(\mathsf{B’D’}\), since \(\mathsf{B}\) and \(\mathsf{D}\) remain fixed at \(\mathsf{0}\). The central minterms — \(\mathsf{m_5, m_7, m_{13},}\) and \(\mathsf{m_{15}}\) — form another quad, producing the implicant \(\mathsf{BD}\), where both \(\mathsf{B}\) and \(\mathsf{D}\) are fixed at \(\mathsf{1}\).
This leaves two remaining 1s at positions \(\mathsf{m_6}\) and \(\mathsf{m_{14}}\). Grouping them together as a pair is valid, but not optimal. These cells can instead be joined with:
- \(\mathsf{m_7}\) and \(\mathsf{m_{15}}\) to form a quad yielding \(\mathsf{BC}\), or
- \(\mathsf{m_2}\) and \(\mathsf{m_{10}}\) to form a quad yielding \(\mathsf{CD’}\).
Both options result in the same cost, so either grouping is acceptable.
Thus, the final simplified function with a cost of 13 (can you calculate?) is:
\[\mathsf{Z\left(A,B,C,D\right)=BD+B’D’+\textsf{ either }BC\textsf{ or }CD’}\].
The solution is graphically presented for better understanding.
Frequently Asked Questions
Do we get different final results by using a different layout of K-maps?
No. It should be noted that it’s unnecessary to solve the function in every possible K‑map layout — for instance, both the \(\mathsf{2\times{}4}\) and \(\mathsf{4\times{}2}\) arrangements of a 3‑input K‑map, or \(\mathsf{4\times{}4}\) and \(\mathsf{2\times{}8}\) and \(\mathsf{8\times{}2}\) of a 4-variable K-map. A single correctly applied layout is sufficient, as all valid layouts will produce the same result.
Are there layouts of a 4-input K-map other than the standard \(\mathsf{4\times{}4}\) form?
Yes. A 4‑input K‑map, can exist in a \(\mathsf{2\times{}8}\) or \(\mathsf{8\times{}2}\) layouts other than the standard \(\mathsf{4\times{}4}\) form. However, \(\mathsf{4\times{}4}\) layout is the standard shape and easiest to work with. The minterms in a \(\mathsf{2\times{}8}\) layout are shown in the figure.
Why is the \(\mathsf{4\times{}4}\) the most used layout of 4-input K-maps?
The inherent symmetry of the \(\mathsf{4\times{}4}\) layout makes it easier to identify the largest possible groups and extract prime implicants compared to other configurations. The following example illustrates this advantage in practice.
When solving the function \(\mathsf{Z = \sum\left(0,2,5,6,7,8,10,13,14,15\right)}\) using the standard \(\mathsf{4\times{}4}\) Karnaugh map, we previously arrived at the simplified expression:
\[\mathsf{Z = BD + B’D’ + \textsf{ either } BC \text{ or } CD’}\]
Now, when attempting the same problem using a \(\mathsf{2\times{}8}\) layout, the groupings appear different at first glance. We immediately notice what seems to be an octet and a separate pair, rather than the three quads we identified in the \(\mathsf{4\times{}4}\) layout. However, upon closer inspection, the apparent octet lacks any constant variable — meaning no valid implicant can be derived from it. This reveals a key challenge in nonstandard layouts: symmetry is less visually intuitive, and valid groupings may be obscured.
If we begin with a single minterm and attempt to expand it stepwise — from a pair to a quad — we quickly realize that the grouping cannot extend to eight cells without violating the requirement for constant variables. Additionally, groupings like the quad formed by \(\mathsf{m_0, m_2, m_8,}\) and \(\mathsf{m_{10}}\) (which yields \(\mathsf{B’D’}\)) are not immediately visible in the \(\mathsf{2\times{}8}\) layout, even though they are valid.
To navigate this, we must recognize that groupings in \(\mathsf{2\times{}8}\) or \(\mathsf{8\times{}2}\) layouts are only valid when they exhibit symmetry around the map’s structural folds — including edge wraparounds. These folds can be visualized as:
- Half folds (shown in pink), dividing the map into two equal parts
- Quarter folds (shown in blue), dividing the map into four symmetric regions
Valid pairs, quads, and octets must align with these folds or wrap symmetrically around them. Once this symmetry is accounted for, the same groupings identified in the \(\mathsf{4\times{}4}\) layout become visible and usable in the \(\mathsf{2\times{}8}\) form.
Thus, while the \(\mathsf{2\times{}8}\) layout is technically correct, it demands greater spatial awareness and fold-based reasoning. The \(\mathsf{4\times{}4}\) layout, by contrast, is inherently symmetric and visually intuitive, making it the preferred and most efficient format for solving 4-variable K-maps.
In both layouts, the final simplified function remains:
\[\mathsf{Z=BD+B’D’+ \text{ either } BC \text{ or }CD’ }\]
Can we take the complement of a function using K-maps?
Yes, we can obtain the complement of a function using K‑maps. Instead of grouping 1s, we carry out the usual K‑map simplification process with the 0s. The largest possible groups of 0s, formed in sizes that are powers of two, will yield the complement of the function in sum‑of‑products form.
Example 7: Express the complement in the simplest form \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\)
We can form three set of octets with the zeros which give the prime implicant A, B and D. The octets are shown in the figure. Therefore, the complement of the function simplifies to:
\[\mathsf{Z’=A+B+D}\]
Can we solve a function using maxterms in K-maps?
Yes — the function can also be solved using maxterms in K‑maps. The process mirrors that for minterms, but instead of grouping 1s, we identify the largest possible groupings of 0s. From these, we write the corresponding constant terms in sum form. Each prime implicant equivalent derived in this way is then combined using the AND gate (·) operator.
Example 8: Express in the simplest form using Maxterms \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\)
We can form three set of octets with the zeros which give the \(\mathsf{A’,B’}\) and \(\mathsf{D’}\). The octets are shown in the figure. Therefore, the function simplifies to:
\[\mathsf{Z’=A’B’D’}\]
Can we take the complement of a function using maxterms in K-maps?
Yes — we can find the complement of a function using maxterms in a K‑map. The approach is the same as the standard maxterm method, but instead of grouping 0s to get the original function, we group the 1s instead. The largest possible groups of 1s, formed in powers of two, give the complement in product‑of‑sums form, with each term representing the constant values across the group.
Example 9: Express the complement in the simplest form using Maxterms \(\mathsf{Z\left(A,B,C,D\right)=\sum\left(0,2\right)}\)
The two 1s at positions \(\mathsf{M_0}\) and \(\mathsf{M_2}\) can be grouped across the edges of the K‑map, forming a valid pair in which variables A, B, and D remain fixed at 0. This grouping corresponds to the Maxterm \(\mathsf{A+B+D}\), which represents part of the complement of the function when simplified using the maxterm approach. The grouping is shown in the figure too.
\[\mathsf{Z’=A+B+D}\]