Propositional logic and Boolean algebra explained
Every statement that is either true or false can be combined with others by and, or, not and if–then, and the truth of the whole follows from the truth of its parts by fixed rules. Those rules are propositional logic. George Boole turned them into algebra in 1854, and eighty years later Claude Shannon showed that the same algebra describes switching circuits. Today it decides what every logic gate in a processor does, and how short a formula can be.
Statements and connectives
A proposition is a statement that is true or false, such as "it is raining". Propositional logic leaves out what the statements say and looks only at how they are joined. Negation ¬P is true when P is false. The conjunction P ∧ Q is true when both are, the disjunction P ∨ Q when at least one is, and exclusive or P ⊕ Q when exactly one is. The implication P → Q is false only when P is true and Q false, and the biconditional P ↔ Q is true when both have the same value.
Truth tables
Because each variable is either true or false, a formula with n variables can be checked completely by trying all 2ⁿ combinations, one row each. The truth table lists them, usually in binary order, and gives the formula's value in every row; columns for the sub-formulas show how the value is built up. Three variables give 8 rows, eight give 256. This brute force always works, which makes propositional logic decidable, but it doubles with every new variable.
Tautologies, contradictions and equivalence
A formula true in every row is a tautology: P ∨ ¬P, or modus ponens, ((P → Q) ∧ P) → Q, the pattern behind every "if this, then that; this, so that". A formula false in every row is a contradiction, and one true in at least one row is satisfiable. Two formulas are equivalent when their truth tables agree in every row, which is the same as saying that their biconditional is a tautology. One row where they differ is enough to show they are not.
Boolean algebra
In 1854 George Boole wrote logic as algebra on the values 0 and 1, with AND as multiplication and OR as a kind of addition. Engineers still write it that way: AB + A'C means (A and B) or (not A and C). The laws look familiar, such as AB = BA and A(B + C) = AB + AC, but some are new: A + A = A, A + AB = A, and De Morgan's laws, (AB)' = A' + B' and (A + B)' = A'B'. In 1937 Claude Shannon showed in his master's thesis that relay circuits obey exactly this algebra, and digital design was born.
Normal forms
Every truth table can be written as a formula, and two standard ways always work. Each true row gives a minterm, an AND of all the variables, each plain or negated as the row says; the OR of these minterms is the disjunctive normal form, written Σm(…) with the row numbers. Each false row gives a maxterm, an OR that is false only in that row; their AND is the conjunctive normal form, ΠM(…). Normal forms prove that AND, OR and NOT are enough for any function, and NAND alone is enough too.
Karnaugh maps
Normal forms are long, and simplifying them by hand with the laws is error-prone. In 1953 Maurice Karnaugh arranged the truth table in a grid whose rows and columns follow the Gray code 00, 01, 11, 10, so that neighbouring cells, also across the edges, differ in one variable. Two neighbouring ones can then be merged into a term with one variable fewer, a block of four into a term with two fewer, and so on. Covering all the ones with as few and as large rectangles as possible gives a minimal sum of products. The method works well up to four variables, and with care up to six.
Quine–McCluskey and prime implicants
For a computer, Willard Quine and Edward McCluskey turned the map into a procedure in the 1950s. Sort the minterms, merge every pair that differs in one variable, and repeat with the merged terms until nothing combines; the terms that never merged are the prime implicants. A prime implicant chart then shows which primes cover which minterms. Primes that alone cover some minterm are essential and must be taken; the rest is a covering problem, solved exactly with Petrick's method or a branch and bound search. Finding the minimum is hard in general, which is why chip design tools use heuristics such as Espresso.
Explore it
Open the truth table calculator and type a formula in the notation you know, from ¬(A ∧ B) to AB + A'C, or start with De Morgan's law, modus ponens, the majority function or a segment of a 7-segment display. See its truth table and classification, its DNF and CNF, the prime implicant chart and the minimal sum and product, and click the Karnaugh map to change the function and watch the shortest formula change with it.
Frequently asked questions
Why is P → Q true when P is false?
An implication only promises something when its condition holds. "If it rains, the street gets wet" is not broken on a dry day, whatever the street does. Defining P → Q as ¬P ∨ Q captures exactly this, and it is what makes rules like modus ponens and contraposition tautologies.
What is the difference between a prime implicant and an essential prime implicant?
An implicant is a product term that is true only where the function is true; it is prime when no literal can be dropped without covering a zero. An essential prime implicant is a prime that is the only one covering some minterm, so every minimal sum must contain it.
Is the minimal sum of products unique?
Not always. Some functions have several covers of the same cost, for example when the prime implicants form a cycle around the Karnaugh map. Each of them is equally good, and a calculator shows one; the minimal product of sums, found from the zeros, can be shorter or longer than the minimal sum.
What does SAT have to do with truth tables?
The satisfiability problem asks whether some row of a formula's truth table is true. Trying every row works but takes 2ⁿ steps, and no fast method is known for every formula: SAT was the first problem shown to be NP-complete, in 1971. Modern SAT solvers still decide formulas with millions of variables in practice by searching cleverly instead of listing rows.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the truth table calculator