A Karnaugh map is an alternative to a truth table for representing a function in boolean algebra, and serve as a way to derive minimum cost circuits for a truth table.

![[karnaugh-maps.png]]

Given the above truth table, the columns are labelled with $x_1$, and the rows are labelled with $x_2$.

To find a minimal boolean expression with a Karnaugh map, we need to find the smallest number of product terms  ($x_1$, $x_2$) that should produce a 1 for all instances where the cell in a table is $1$. 

# Two Variable Maps

![[Pasted image 20250224104850.png]]

- Given the map described in the above image, the output is $1$ for the row where $x_2$ is equal to 1.
- Similarly, the output is $1$ for the column where $x_1$ is equal to zero.
- By ORing the condition where $x_1$ is zero ($\overline{x_1}$), and the condition where $x_2$ is one ($x_1$), we can find a minimal expression for the truth table.

# Three Variable Maps
![[Pasted image 20250224105753.png]]

A three variable Karnaugh map is constructed by placing 2 two-variable maps side by side. The values of $x_1$ and $x_2$ distinguish columns in the map, and the value of $x_3$ distinguishes rows in the map.

To convert a 3 variable Karnaugh map to a minimal boolean expression, start by looking for places in the map that contain 1s next to each other (by row, or by column).

![[Pasted image 20250224110124.png]]

From there, describe the pair of 1s using boolean algebra.

In the above example, the top pair of 1s is in the column where $x_3$ is equal to zero ($\overline{x_3}$), and $x_1$ is equal to $1$ ($x_1$). This describes a single term in the resulting equation ($x_1\overline{x_3}$).


![[Pasted image 20250224110632.png]]
> Similar logic can be employed using more than just a *pair* of ones.


# Four Variable Maps
![[Pasted image 20250224111117.png]]
![[Pasted image 20250224110819.png]]