Classification
True rows
Variables
Minimal sum of products
Minimal product of sums
Canonical DNF (sum of minterms)
Written out
Canonical CNF (product of maxterms)
Written out

★ essential prime · ⊗ the only prime of that minterm · shaded rows: the chosen cover

Notation

More information about propositional logic and Boolean algebra

Truth table and Boolean algebra calculator

Is ¬(A ∧ B) the same as ¬A ∨ ¬B? Is ((P → Q) ∧ P) → Q always true? And what is the shortest formula for a function you only know from its table? Type a formula the way you are used to, with ¬ ∧ ∨ → ↔ from logic or AB + A'C from digital electronics, and see its truth table, whether it is a tautology, its canonical normal forms and its simplest sum of products, found with the Quine–McCluskey method and drawn as groups on a Karnaugh map. Click the map to change the function and watch the formula follow. Type a formula or pick an example. The truth table, the normal forms, the minimal sum of products and the Karnaugh map follow as you type. Click a cell of the Karnaugh map or a value in the last column of the truth table to switch it between 0 and 1: the formula becomes the minimal sum of products of the new function. Type a second formula under Compare with to test whether the two are equivalent; if they are not, the first row where they differ is shown.

How it works

  1. Type a formula, such as (P → Q) ∧ P or AB + A'C, or choose an example; the symbol keys insert ¬ ∧ ∨ ⊕ → ↔ on a phone.
  2. Read the classification, the truth table with its true rows highlighted, the canonical DNF and CNF, and the minimal sum and product.
  3. Click a cell of the Karnaugh map or a value in the truth table to define a function directly, or type a second formula to test whether the two are equivalent.

From formula to truth table

A formula with n variables has 2ⁿ rows in its truth table, one for every way of setting each variable true or false. The calculator reads the formula with the usual precedence (NOT before AND, AND before XOR, XOR before OR, then implication and equivalence), shows it again with standard symbols, and works out every row, with a column for each sub-formula if you want to follow the steps. A formula true in every row is a tautology, one false in every row a contradiction, and anything in between is satisfiable.

Normal forms and the shortest formula

Every true row gives a minterm, and the sum of the minterms is the canonical disjunctive normal form; the false rows give the maxterms of the conjunctive normal form. These forms are exact but long. The Quine–McCluskey method merges minterms that differ in one variable until only prime implicants are left, and an exact search then picks the cheapest set of primes that covers every true row: the minimal sum of products, the formula a Karnaugh map gives when its groups are chosen well.

Frequently asked questions

Which notations can I type?

Logic symbols (¬ ∧ ∨ → ↔ ⊕ ↑ ↓), keyboard forms (~ ! & && | || -> => <-> <=> ^), words (NOT, AND, OR, XOR, NAND, NOR, XNOR, IMPLIES, IFF) and the engineering style, where letters side by side are multiplied and an apostrophe negates: AB + A'C. The constants are 0, 1, T, F, true and false, and Σm(1,3,5) or ΠM(0,2) give a function by its minterms or maxterms.

In which order are the operators applied?

NOT binds tightest, then AND (with NAND), XOR, OR (with NOR), implication and finally equivalence. So A ∨ B ∧ C means A ∨ (B ∧ C), and A → B ↔ C means (A → B) ↔ C. Implication groups to the right: A → B → C is A → (B → C). Brackets always win, and the formula is shown again with the brackets that make its reading clear.

What is a minimal sum of products?

An OR of AND terms that has the same truth table as your formula and uses as few literals as possible (and then as few terms). The calculator finds every prime implicant with the Quine–McCluskey method and then searches exactly for the cheapest cover, starting with the essential primes, the only ones covering some true row. The prime implicant chart shows which primes cover which minterms.

How do I read the Karnaugh map?

Each cell is one row of the truth table, arranged in Gray-code order (00, 01, 11, 10) so that neighbouring cells differ in exactly one variable, also across the edges. A rectangle of 1, 2, 4 or 8 cells full of ones is one product term: the variables that stay the same inside it. The coloured rectangles are the groups of the minimal sum, and a group that wraps round an edge is drawn in pieces.

How many rows does a truth table have?

2ⁿ for n variables, because each variable doubles the number of combinations: 4 rows for two variables, 8 for three, 16 for four. The calculator handles up to 8 variables, which is 256 rows.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Go to Editor