Resources | Subject Notes | Computer Science
Boolean logic is a fundamental concept in computer science, used extensively in digital circuits and programming. It deals with logical operations on binary values (True/False or 1/0). This section covers how to translate problem statements, logic circuits, and truth tables into Boolean logic expressions.
The main Boolean operators are:
Here's how to translate common phrases into Boolean expressions:
Example: If a student passes the exam (A) and scores above 50% (B), then they get a certificate. The Boolean expression is: $A \land B$
Logic circuits visually represent Boolean logic. To translate a circuit, trace the signal flow and identify the Boolean expressions corresponding to each gate.
Example: Consider a circuit with an AND gate connected to inputs A and B. The output of the AND gate is $A \land B$
Truth tables show the output of a Boolean expression for all possible input combinations. You can construct a Boolean expression from a truth table using the following steps:
Example: Consider the following truth table:
A | B | Output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
The output is 1 when (A=0 and B=1) or (A=1 and B=0) or (A=1 and B=1). This can be represented as: $(\neg A \land B) \lor (A \land \neg B) \lor (A \land B)$
Problem: Write a Boolean expression for the statement: "The light is on if the switch is flipped and the power is on."
Solution: Let A represent the switch being flipped and P represent the power being on. The Boolean expression is: $A \land P$
Problem: Consider a logic circuit with two inputs, X and Y, connected to an OR gate, and the output of the OR gate connected to a NOT gate. Write a Boolean expression for the output.
Solution: The output of the OR gate is $X \lor Y$. The NOT gate inverts this, so the output is $ \neg (X \lor Y) $
Problem: Here's a truth table. Write a Boolean expression for it.
A | B | Output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 0 |
Solution: The output is 1 when B=1 and A=0. This can be expressed as: $ \neg A \land B $