Type any Boolean expression with up to five variables and this generator writes its complete truth table, with a column for every step of the working. Add a second expression to check whether the two are equivalent, which is the quickest way to verify De Morgan's laws and other Boolean identities. It is meant for the Boolean logic part of Class 11 and Class 12 Computer Science.
. * & for AND, + | for OR, ~ ! or a quote after (A') for NOT, ^ for XOR. Letters next to each other (AB) mean AND. Up to 5 variables.What a truth table shows
In Boolean logic every variable has only two values: 1 (true) and 0 (false). A truth table lists every possible combination of inputs and the output for each one. With n variables there are 2n rows: 2 variables give 4 rows, 3 give 8 rows and 5 give 32 rows. The rows are written in binary counting order, 000, 001, 010 and so on, so none is missed.
The basic gates
| A | B | NOT A | A AND B | A OR B | A XOR B | A NAND B | A NOR B |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
- AND (A.B) is 1 only when both inputs are 1.
- OR (A + B) is 1 when at least one input is 1.
- NOT (A') turns 1 into 0 and 0 into 1.
- XOR (A ⊕ B) is 1 when the inputs are different. A XOR B = A.B' + A'.B
- NAND = NOT (A AND B) and NOR = NOT (A OR B). They are called universal gates because any circuit can be built using only NAND gates, or only NOR gates.
How the generator reads your expression
Like BODMAS in arithmetic, Boolean operators have an order. The generator uses the usual order: brackets first, then NOT, then AND (and NAND), then XOR, then OR (and NOR). Operators of the same level are worked from left to right. So A + B.C means A + (B.C), not (A + B).C. The line "F is read as" above the table shows exactly how your expression was bracketed, so you can see if it matches what you meant. NAND and NOR do not give the same answer when regrouped, so with three inputs always write the brackets, for example (A NAND B) NAND C.
You can write AND as the word AND or as . or *, OR as the word OR or as +, and NOT as the word NOT, as ~ or as a quote after the term (A'). Letters written side by side, such as AB, mean A AND B, as in textbook Boolean algebra. Small and capital letters are treated as the same variable.
Worked example: proving De Morgan's first law
Question: Using a truth table, prove that (A.B)' = A' + B'.
Make one column for each part: A.B, then its complement on the left side; A', B' and their sum on the right side.
| A | B | A.B | (A.B)' | A' | B' | A' + B' |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
The two bold columns are the same in all four rows (1, 1, 1, 0), so (A.B)' = A' + B'. Hence proved. Both sides are 1 in rows 0, 1 and 2, so in minterm form each is Σm(0, 1, 2), and each is 0 only in row 3, which is ΠM(3). The calculator above is already set to this example (F = NOT (A AND B), G = NOT A OR NOT B) and shows the same columns.
De Morgan's second law, (A + B)' = A'.B', is proved the same way: both sides are 1 only when A = 0 and B = 0. Press "De Morgan 2" to see it. In words, the two laws say: break the bar and change the sign (AND becomes OR, OR becomes AND).
Common mistakes
- Treating (A.B)' as A'.B'. The complement of a product is the sum of complements: (A.B)' = A' + B'.
- Working A + B.C from left to right as (A + B).C. AND is done before OR unless brackets say otherwise.
- Missing rows. With 3 variables there must be 8 rows; count in binary from 000 to 111.
- Thinking XOR is the same as OR. When both inputs are 1, OR gives 1 but XOR gives 0.
- Proving an identity from only one or two rows. Two expressions are equal only if they match in every row of the table.