calculator.onl
Categories50

Boolean logic, truth table and Karnaugh map calculator

Analyze a Boolean expression, minimize SOP and POS, and check every required truth-table row.

A worked example

Switch from AND to OR. Which rows on the switchboard light up?

Minimal sum of products (SOP)ARequired true rows2Truth-table rows4
Select the declared variables A, then B, C and D. A is the most significant bit of the row index. Unused declared variables still appear in the table.

Enter constants 0 and 1, the declared variable letters, and explicit operators. Precedence, highest first: NOT (!, ~, NOT or postfix apostrophe), AND (&, *, AND), XOR (^, XOR), OR (|, +, OR). Parentheses override precedence. Letter case is ignored; implicit AB multiplication is not accepted.

Optional row indices where either output is acceptable. Separate distinct indices with semicolons or whitespace; decimal integers only. These indices override the expression only for minimization.

Updates as you type

Use the stated ranges and input grammar. Enter finite values and decimal dots. Inactive fields are ignored.

YOUR RESULT

Minimal sum of products (SOP)

A

Calculated from your inputs

Minimal product of sums (POS)A
Variable count2
Truth-table rows4
Required true rows2
Equivalence on required rowsVerified on every required row
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

The first expression is true whenever A is true, while the second additionally requires B to be true. Change “Boolean expression” from (A & B) | (A & !B) to A&B and keep the other inputs from the worked example. The value for “Required true rows” goes from 2 to 1. For a related calculation, try Bitwise calculator: AND, OR, XOR and shifts.

What to enter

InputWhat it meansExample value
Variables in orderSelect the declared variables A, then B, C and D. A is the most significant bit of the row index. Unused declared variables still appear in the table.2 · A, B
Boolean expressionEnter constants 0 and 1, the declared variable letters, and explicit operators. Precedence, highest first: NOT (!, ~, NOT or postfix apostrophe), AND (&, *, AND), XOR (^, XOR), OR (|, +, OR). Parentheses override precedence. Letter case is ignored; implicit AB multiplication is not accepted.(A & B) | (A & !B)
Don’t-care row indicesOptional row indices where either output is acceptable. Separate distinct indices with semicolons or whitespace; decimal integers only. These indices override the expression only for minimization.

How the calculation works

  1. Parse the expression safely and evaluate it for every combination of the declared variables.
  2. Build canonical minterm and maxterm forms. Enumerate valid Boolean cubes and find a minimum cover of required 1 rows for SOP and required 0 rows for POS.
  3. Show each chosen group on the Gray-code Karnaugh map and verify both simplified forms against every row not marked X.
The formulaN = 2ⁿ; SOP = Σ(minterms); POS = Π(maxterms)

A worked example

Our example: (A & B) | (A & !B) has required 1 rows 2 and 3. Both minimal SOP and POS equal A, with four truth-table rows and verified equivalence.

Example you can load

What to enter
Result for this example · Minimal sum of products (SOP)A

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

1–4 variables named A–D in that order; at most 16 rows, 512 input characters and 32 nested parser levels. The exact cover minimizes term count first and literal count second, independently for SOP and POS. Equal-cost answers may exist. No timing, hazards, gate-cost or multi-output optimization. Don’t-care rows may differ between the two simplified forms.

Frequently asked questions

What does don’t-care mean?

It means the input combination is outside your required behavior. The simplifier may use it as 0 or 1; do not mark an ordinary valid case as don’t-care.

Is the result the fewest possible logic gates?

No. The optimization is exact for two-level term count, then literal count. Actual gate libraries, timing and shared subexpressions can favor a different circuit.

Why can SOP and POS differ on X rows?

Each form is minimized separately. Both must match all required rows but can choose different values on unspecified rows.