Boolean Logic Explained
Boolean Logic Explained
Learn all about logical operators, truth tables, Boolean algebra and
their application in real-world scenarios with this guide.
Here you’ll find key terminology, theory explained, examples and
some problems with answers.
2
Contents
Introduction to Boolean Logic
Logical Operators
Truth Tables
Boolean Algebra
Real-World Application
Problems
Answers
3
In short, Boolean logic is a mathematical system based on true and false values. It’s
the backbone of computational logic used in computing, electronics, artificial
intelligence, and logical reasoning.
In the next chapter, we will dive deeper into logical operators, which allow us to form
complex logical expressions.
4
2.2 Negation (¬ or !)
Negation is the simplest logical operator. It is used to reverse the truth value of a
proposition. If a proposition P is true, its negation (¬P) is false, and if P is false, its
negation (¬P) is true. It’s represented by the “¬” symbol.
The “¬” symbol is read out as not.
By definition:
If P is true, then ¬P is false.
If P is false, then ¬P is true.
Here’s how it looks with numbers:
¬0 = 1 and ¬1 = 0
And with propositions:
¬True = False and ¬False = True
false, the conjunction is false. It’s represented by the “∧” symbol, which reads out as
“and”.
By definition:
If P is 0 and Q is 0, P ∨ Q is 0 (False)
If P is 1 and Q is 0, P ∨ Q is 1 (True)
6
If P is 1 and Q is 1, P ∨ Q is 1 (True)
In Computer Science implication is not often represented or widely used but its
behavior can be simulated using some conditional if statements. Here’s how it looks in
python:
*The conditional structure in the if’s is possible due to the properties of the logical
operators. They’re similar to the algebraic operations addition and multiplication.
This chapter explains every common logical operator along with its counterpart in
Computer Science. It goes over each operator’s functions through definition and code
examples, demonstrating how it’s used in both formal logic and CS. In the next
chapter we’ll cover how to visualize these results properly using elegant truth tables.
10
P ¬P
True False
False True
Here's the full truth table for all the reviewed logical operators:
P∧Q P∨Q
AND OR IMPLICATION EQUIVALENCE
P Q
P→Q P↔Q
True True True True True True
True False False True False False
False True False True True False
False False False False True True
As you can see, the truth table provides a structured and elegant system to represent
the truth value of input and output information, making it an essential tool for
Up to now we’ve only looked over basic Boolean expressions such as P ∧ Q and P ↔
Computer Science and Programming, Digital Circuit Design and Boolean Algebra.
Q. In the next chapter we’ll learn how to work with more complex Boolean structures
as well as learn how to create custom Boolean expressions.
11
Boolean Algebra allows us to transform Boolean expressions into a more readable and
obviously 0. This may not seem that important in this example but if we were to have
a more complex Boolean expression, these rules come in real handy.
We have 0 ∧ 1 ∧ 0 ∨ 1.
For example:
(0 ∨ 1 ∨ 0) ∧ (1 ∨ 0) ∧ 0 ↔ 1
Here’s one more example:
Since it’s obvious that 0 does not equal 1, we can say that the expression (0 ∨ 1 ∨ 0)
0=1
Formerly, these cool tricks come from rules known as Boolean Laws and Properties.
Let’s take a look at them.
A∧1=A
A∨0=A
A∧0=0
2. Null Laws
A∨1=1
A∧A=A
3. Idempotent Laws
A∨A=A
A∧A=0
4. Complement Laws
A∨A=1
A∧B=B∧A
5. Commutative Laws
A∨B=B∨A
(A ∧ B) ∧ C = A ∧ (B ∧ C)
6. Associative Laws
(A ∨ B) ∨ C = A ∨ (B ∨ C)
A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
7. Distributive Laws
A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)
A ∨ (A ∧ B) = A
8. Absorption Laws
A ∧ (A ∨ B) = A
9. De Morgan’s Theorems
A ∧ B= A ∨ B
A ∨ B= A ∧ B
(A ∧ B) ∨ (A ∧ B )
Consider the expression:
A ∧ (B ∨ B )
Using the Absorption Law, this simplifies to:
Since B ∨ B = 1, we get:
A∧1=A
13
Boolean logic and Boolean algebra are fundamental in computer science, engineering,
and everyday problem-solving. This chapter explores various real-world applications
of Boolean logic and algebra, demonstrating their significance in different fields.
6.3Truth Tables
Given the Boolean expression A ∧ (B ∨ C), construct the truth table for all
Given the Boolean expression (A ∨ B) → C, construct the truth table for all
possible combinations of A, B and C.
possible combinations of A, B and C.
Chapter 7: Answers
7.1 Introduction to Boolean Logic
0 and 1; Yes and No; True and False
colors, screen brightness, answers to Yes/No questions, temperature, fan speed,
light switch, door locks, pixel states in colorful images, pixel states in black-
and-white images, speaker volume, bits in computer systems?
On each login attempt the credentials (username and password) are checked. If
the username is matched to a profile and the password matches the one in the
profile, access is granted (output 1). If either the username or the passwords are
mismatched, access is denied (output 0).
A B C B∨C A ∧ (B ∨ C)
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 1 0
1 0 0 0 0
1 0 1 1 1
1 1 0 1 1
1 1 1 1 1
A B C A∨B (A ∨ B) → C
0 0 0 0 1
0 0 1 0 1
0 1 0 1 0
0 1 1 1 1
1 0 0 1 0
1 0 1 1 1
1 1 0 1 0
19
1 1 1 1 1