K Map Solver – Karnaugh Map Calculator

Build a Karnaugh map from minterms, maxterms or a truth table, then get a fully simplified Boolean expression with colored groupings. Supports 2–6 variables and don't-care conditions.

1. Define your Boolean function

Tip: click cells to toggle 0 → 1 → X (don't-care).

2. Edit the Karnaugh map

Gray code ordering is used on rows and columns. For 5–6 variables, two 4-variable maps are stacked as separate planes.

3. Simplify the Boolean expression

The solver finds prime implicants and selects a minimal cover using a Quine–McCluskey style algorithm adapted to K maps.

Results

Simplified Sum of Products (SOP)


                

Simplified Product of Sums (POS)


                

Prime implicants & groups

    How this K map solver works

    This Karnaugh map calculator lets you simplify Boolean expressions for 2, 3, 4, 5 and 6 variables. You can start from minterms, maxterms or a full truth table, then interactively edit the K map and see the minimized SOP and POS forms.

    Supported input formats

    • Minterms (SOP): list the decimal indices where the function is 1. Example for 4 variables: 1,3,7,11,15 or ranges like 0-3,8-11.
    • Maxterms (POS): list the indices where the function is 0. The solver internally complements them.
    • Truth table: a comma- or space-separated list of 0, 1 and X (don't-care) values in ascending index order.

    After building the map, you can click any cell to toggle between 0 → 1 → X. X cells are treated as don't-cares: they may be used to form larger groups but do not force the output to be 1.

    Gray code ordering

    K maps use Gray code ordering so that adjacent cells differ by only one variable. For example, with 4 variables:

    Row labels (AB): 00, 01, 11, 10

    Column labels (CD): 00, 01, 11, 10

    The solver automatically arranges rows and columns in Gray code and maps each minterm index to the correct cell.

    Grouping rules used by the solver

    • Groups must contain only 1s and optional don't-cares (X).
    • Group sizes are powers of two: 1, 2, 4, 8, 16, …
    • Groups can wrap around edges (top–bottom, left–right, and between planes for 5–6 variables).
    • Each 1 must be covered by at least one group; essential prime implicants are always included.

    Internally, the tool enumerates candidate groups, filters prime implicants, then selects a minimal cover using a heuristic similar to the Quine–McCluskey method but optimized for the K map geometry.

    From groups to Boolean terms

    Each group corresponds to a product term (for SOP) or a sum term (for POS). Variables that change within the group are eliminated; variables that stay constant appear in the term.

    Example (4 variables A, B, C, D):

    • A group covering cells where A = 1 and B = 0, while C and D vary, gives the term A B'.
    • A group covering cells where C = 0 only gives the term C'.

    Example: 4-variable K map simplification

    Suppose you have minterms m(1,3,7,11,15) for variables A, B, C, D.

    1. Enter 1,3,7,11,15 as minterms and build the K map.
    2. The solver finds two groups: one group of 4 and one group of 2 cells.
    3. It outputs something like:

      SOP: \( F(A,B,C,D) = A' C D + B C D \)

    When to use a K map vs. algebraic methods

    • K maps: best for up to 5–6 variables; they give a visual, intuitive simplification.
    • Algebraic methods / Quine–McCluskey: scale better to many variables but are harder to do by hand.

    This solver combines both: it uses the K map layout for visualization and a systematic algorithm to guarantee a minimal or near-minimal expression.

    Common mistakes K maps help you avoid

    • Forgetting wrap-around adjacency on the edges.
    • Using groups that are not powers of two.
    • Missing essential prime implicants.
    • Not using don't-care cells to form larger groups.

    By highlighting each group in a different color and listing the corresponding term, this tool makes it easy to verify your manual solution or learn the technique step by step.

    FAQ

    Can this K map solver handle multiple output functions?

    This version focuses on a single output function at a time. To simplify multiple outputs, solve each function separately using the same truth table inputs.

    How are 5- and 6-variable K maps displayed?

    For 5 variables, the map is split into two 4-variable planes (e.g., A=0 and A=1). For 6 variables, two planes are used for the two most significant variables. The solver still returns a single simplified expression in terms of all variables.

    What notation is used for complements?

    By default, the solver uses a prime notation such as A' for NOT A. You can copy the expression directly into most digital logic textbooks or convert it to overbar notation if needed.