Boolean Algebra
Learn the laws of Boolean algebra, including De Morgan's laws, and use them to simplify expressions step by step and check the result with a truth table.
Definition
| Law | AND form | OR form |
|---|---|---|
| Identity | ||
| Null (domination) | ||
| Idempotent | ||
| Complement | ||
| Double negation | (only one form) | |
| Commutative | ||
| Associative | ||
| Distributive | ||
| Absorption | ||
| De Morgan |
Try it now
Worked Examples
Simplify .
Use the identity law on the first bracket
, because AND with true changes nothing →
Use the null law on the second bracket
, because AND with false is always false →
Use the identity law again
, because OR with false changes nothing →
Answer: . The value of does not matter at all.
Common Mistakes
Writing
Why it's wrong: De Morgan's law flips the operator as well as the variables. Test , : the left side is , the right side is .
Correct: Break the bar and change the sign: and .
Using rules of ordinary algebra, such as or
Why it's wrong: Boolean variables are only 0 or 1, and is 1, not 2. Repeating a variable adds nothing new.
Correct: Use the idempotent law: and .
Reading as
Why it's wrong: AND is evaluated before OR, just like multiplication before addition. With , , the correct value is , but the wrong reading gives .
Correct: Add the brackets before you apply a law: .
Using the complement law on two different variables, as in
Why it's wrong: The complement law only works for a variable and its own negation. With , : , not 0.
Correct: Look for the same letter: and , but cannot be simplified.
Interactive Visual
Truth Table
| A | B | A ∧ B | ¬B | A ∧ ¬B | A ∧ B ∨ A ∧ ¬B |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 |
1= True0= False
Truth Table
| A | B | A ∧ B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
1= True0= False
Interactive Sandbox
Expression Calculator
Try these:
History
No calculations yet
Practice Problems
18 problemsWhich law says ?
Why It Matters
- Electronics: a processor contains billions of gates, so saving one gate in a circuit that is copied a million times saves a million gates
- Programming: a condition like NOT (weekend OR holiday) can be rewritten as (NOT weekend) AND (NOT holiday), which is often easier to read and test
- Search and databases: a filter such as math OR (math AND logic) gives exactly the same results as just math
- Proofs: the laws let you prove that two circuits or two conditions do the same job without trying every input
Real World Applications
Designing Cheaper Chips
Chip designers simplify every circuit with Boolean algebra before it is built, because each gate costs space, power and money.
Example:
A circuit for uses 3 gates. Factored as , it needs only 2.
A chip contains 1000 copies of a circuit that computes . Count one gate for each and each .
How many gates does the whole chip save when the circuit is simplified to ?
Step 1: Write the mathematical expression
Write the saving as a calculation:
Readable Program Conditions
Programmers use De Morgan's laws to remove confusing double negations from conditions in their code.
Example:
NOT (weekend OR holiday) is the same as (NOT weekend) AND (NOT holiday): the shop is open on days that are neither.
A program opens a barrier if , where means the visitor has a pass and means the visitor is on the guest list.
What is the simplest form of the condition, and how many NOT operators does it remove?
Step 1: Write the mathematical expression
Write the number of NOT operators before and after as a subtraction:
Search Filters
Search engines and databases simplify filters with the absorption law before they run them.
Example:
The filter math OR (math AND logic) returns exactly the same books as the filter math.
A library has 40 math books, and 15 of them are also about logic. A reader searches for math OR (math AND logic).
How many books does the search return?
Step 1: Write the mathematical expression
Add the math books and the extra books that (math AND logic) brings in:
Key Takeaways
- 1Boolean algebra uses laws to rewrite an expression into an equivalent one, without a new truth table each time
- 2Identity, null, idempotent and complement laws remove constants and repeated variables: , , ,
- 3Commutative, associative and distributive laws reorder, regroup and factor; in Boolean algebra OR also distributes over AND
- 4Absorption laws: and
- 5De Morgan's laws: break the bar and change the sign, and
- 6Simplify one law at a time, name each law and check the result with a truth table; a simpler expression means fewer gates
Frequently Asked Questions
Glossary
- Boolean algebra
- The set of laws for rewriting and simplifying Boolean expressions
- Law
- An equivalence that holds for every value of the variables, such as
- Equivalent
- Having the same truth value in every row of the truth table
- Simplify
- Rewrite an expression with fewer operators while keeping it equivalent
- De Morgan's laws
- and
- Absorption law
- and
Formula Card
Identity and null laws
AND with 1 and OR with 0 change nothing; AND with 0 and OR with 1 decide the result
Idempotent and complement laws
Repeating a variable adds nothing; a variable with its own negation gives a constant
Double negation
Two NOTs cancel each other out
Distributive laws
Both hold in Boolean algebra; the second one does not work for ordinary numbers
Absorption laws
The longer part is swallowed by $A$
De Morgan's laws
Break the bar, change the sign