Boolean logic is a binary logic system, meaning that it takes into account two possible states: 0 and 1.For example, 0 could represent the state "false" and 1 could be "true".
Boolean logic is really just a set of rules for the manipulation of given inputs. It consists of a set of "logic gates", each of which is a different set of rules. The three main logic gates are AND, OR, and NOT. AND and OR require two inputs, whereas NOT only requires one. Here is an explanation of each gate:
AND
It can be written like this: ∩ (ie. "p AND q" can also be written as "p ∩ q")
When two inputs are entered into the AND gate, the output is always 0 unless both inputs are 1. Here is a truth table for the AND gate:
p | q | p AND q |
1 | 1 |
1 |
1 | 0 |
0 |
0 | 1 |
0 |
0 | 0 |
0 |
OR
It can be written like this:ᴗ (ie. "p OR q" can also be written "pᴗ q")
When two inputs are entered into the OR gate, the output is always 1 unless both inputs are 0. Here is a truth table for the OR gate:
p | q | p OR q |
1 | 1 |
1 |
1 | 0 |
1 |
0 | 1 |
1 |
0 | 0 |
0 |
NOT
It can be written like this: -(ie. "NOT p" can also be written as "-p")
When an input is entered into the NOT gate, the output is the opposite of that input. In other words, if the input is 1, the output is 0. And if the input is 0, the output is 1.
Since both the input and output for a gate are ones and zeros, the output from one gate can serve as the input for another. Two or more gates linked in this fashion are called a logic network. The truth table still functions the same way. For example, consider the network below.
p | q | NOT((p AND q) OR q) |
1 | 1 |
0 |
1 | 0 |
1 |
0 | 1 |
0 |
0 | 0 |
1 |
P and q are both inputs to the AND gate. Then, the output from the AND gate and q are inputs for the OR gate. The output from the OR gate is input for the NOT gate. The output from the NOT gate is the final result for the whole network.