Logical Operators, So what? Why are they important? What can they do?

Christopher Minn

Logical operators are all around us. Whether you realize it or not, when you make a decision of eating cereal and milk for breakfast, choosing between pasta or rice for lunch, or choosing not to study for an exam despite your lack of preparation (which is occurring to me as I write this), all of these statements contain a logical operator. the most common operators seen around consist of AND, OR, NOT, and a combination of these three in order to produce other outputs. Eating cereal AND milk, pasta OR rice, and choosing NOT to study all embody these different operators. Now, in math, these operators also play a crucial part in producing some of the foundations that can be used to build a deeper understanding of simple logic. For example, different truth tables that can be constructed from the basics of AND, OR, and NOT operators. However, in math, these operators are actually represented as the following: AND as \wedge, OR as \vee and NOT as \neg. Below, I will include a basic truth table to demonstrate how these operators operate (no pun intended) in math.

As you can (hopefully) see, P and Q represent different variables that can be either true or false, and depending on the logical operator applied, the outputs differ. As I mentioned earlier, it’s also possible to combine these operators and make more deceptively complex looking outputs, that actually are not too horrendous when taken one step at a time. I’ll include another truth table showing how some of these operators can be combined to do this.

Hopefully, you now are familiar enough with these basic logic operators to apply them in different contexts, because that’s the very next step! Believe it or not, computer science, computer engineering, and electrical engineering carry these exact same concepts just disguised to look a little different. While in these fields there are also truth tables to be written, these are almost identical to the math aspect, so I’ll show you how different circuits can use these logical operators to produce different outputs. For these demonstrations, I will be using an IC chip, which means integrated circuit, which basically means there’s a lot of wiring under the chip that allows for the logical operators to produce the desired outputs when given inputs. Also, I’ll also have a LED strip that lights up when the output of the two inputs are true, similar to the truth tables described above for math. Finally, I will be using a DIP switch, which essentially is able to control whether an input is fed as true or false depending on if it is switched to on or off).

Present in the photo are: LED strips (red), DIP switch (blue), and IC chip (black)

So obviously there is no way you can tell what gates do what, but I assure you that by the end of this post, you will at least have a general understanding about how these gates relay information. Just like in math, there are different gates that produce different outputs, in such a way that they also correspond to AND, OR, and NOT (what a coincidence)! To understand how these gates work, though, I’ll provide a quick crash course on how IC chips work. The chip must be plugged into a power and ground supply in order to produce the true and false output, and these wires (for the purposes of this post) will be in red and black, respectively, and don’t do anything except power the actual device. The wires that we will want to focus on, however, will be denoted in different colors throughout the presentation. You can imagine the inputs as something similar to P and Q in terms of mathematics. They will be plugged in two different gates,  which are essentially the place where the wires are input (and where the output will come from as well)! The wire version of these two inputs will be placed into an IC chip where their inputs will be interpreted, and their output given in a separate gate. And also, while in computer engineering the tables sometimes do utilize T and F, the more common notation is 1 and 0, for true and false respectively.

The AND Gate

Now that there is a more brief outline of how the wiring works, I will begin with the and gate. The and gate functions exactly how you would expect it to based off the mathematical interpretation, where if both inputs are 1 (true), the output will also produce a 1 (true). Below is a picture of how this functions.

AND Gate Diagram

In the diagram, the gate is drawn to where both inputs (P and Q) are false. In this form, the power is not able to reach the output, and thus the LED will not light up. However, if both gates are set to true (the wires would be put down and connect), there would be a straight path to the output, meaning the LED would light up. I will now include pictures of how the actual and gate works below (pay specific attention to the first two switches, green, yellow, and white wire!)


As you can see in the images, when both switches are flipped to on, the LED lights up.  Just as a reference, the green wire is the “P” value, the yellow wire is the “Q” value, and the white wire carries the output. However, when one switch is on and the other is off, the LED does not turn on. And finally, when both switches are off, the LED also, as expected, does not turn on. Hopefully you are able to see the parallel between mathematics here!

The OR Gate

Next, I will explain how the or gate works. Once again, similar to mathematics, the or gate returns a true value when at least one of the two given inputs are true. Below, I will also attach a photo of how this gate works.

OR Gate Diagram

In the diagram, the gate is drawn once again to where both inputs (P and Q) are given as false. However, contrary to the first diagram, if one of the two values are given as true, the power will be able to flow to the output (in breadboarding, as long as one path reaches the output, it is considered as working). I will again include pictures of how the actual gate works (like last time, pay specific attention to the two switches, green, yellow, and white wire!)


Once again, per the images, when one switch or both switches are flipped to on, the LED lights up. However, when both switches are off, the LED is off. Also, the wire coding stays the same for these images (green for P, yellow for Q, white for output, in case you need a refresher).

The NOT Gate

Finally, the not gate is the last gate I will be covering in today’s post. Just like in math, it negates the output and gives a false value when the initial value is true, or a true value if the initial value is false. Below, I will once again attach a photo of how this gate works.

NOT Gate Diagram

In the diagram, the one gate (P, this time), is also drawn as giving false. However, contrary to the two previous diagrams, P being false implies that the negation would be true, thus allowing power to go to the LED and turn on. I will include pictures of the real gate again below (one last reminder to pay specific attention to the one switch this time, green, and white wire!)

This time, I have opted to just display the P value through the green wire and the output value through the white wire. As expected for a negation, when the switch is off, the LED turns on, and when the switch is on, the LED does not turn on.

Putting Logic Gates Together

Now, just like in math, computer engineering is no fun when the outputs are direct and simply derived. In these next image, I will be giving you the initial inputs of the P and Q values for the wires, putting them through a series of gates, and asking you to try to derive the correct answer. While of course drawing out a truth table is good practice for ensuring your logic is right, try to solve it based off the wires first!

A Challenge Question

For this question, P is initially true and Q is initially false, and the output result is true using two operators. The green wire is P, and the yellow wire is Q. The white wire carries the first operation’s output into the blue wire. (Hint: There are technically multiple correct answers, but only one that uses this specific amount of wiring!)

Hopefully you were able to reason through the problem presented. Obviously, while this only displays a smaller demonstration of what these gates can do, the larger implications can be seen in many applications of computer engineering! For example, by combining different gates together that perform these operations, you can construct a machine that is able to perform addition, coordinate traffic lights, or for the sake of the mathematicians reading this, calculate the GCD. I’ll include a picture of my most recent circuit that can compute the GCD given two binary inputs below.

A GCD Calculator

For all of you who made it this far, thank you for reading and I hope that this provided you some insight in how the logical operators work for math, computer science/engineering, or both!

Answers to the challenge question: AND + NOT (other acceptable answers include: OR + OR, NOT + AND) – Justification for AND + NOT – this is technically the correct answer since two wires are needed to perform the AND operator as shown in the image (similar to how AND requires two inputs), and then the negation requires one operator.

2 Comments

  1. Hi Chris, thank you so much for your wonderful posting. This reminds me of something I learned in a different class related to the probability of failure in parallel and serial systems. Suppose that P and Q are two components that function independently of one another, which means their chances to fail in use are independent. In parallel systems, a scenario similar to the And gate in your post, the probability that the entire system fails to function equals P’s probability of failure plus Q’s probability of failure. In serial systems, a scenario similar to the Or gate in the post, the probability that the entire system fails to function equals P’s probability of failure times Q’s probability of failure. This totally makes sense in terms of logic operators. In the first case, the system fails when either of the two components stops functioning, which in logic operators, corresponds to not P or not Q (in other words, not P and Q). Since the two components function independently, this leads us to directly adding P’s probability of failure and Q’s probability of failure, which will give us the probability that the system fails as a whole. In the second case, the system fails when both of the components stop functioning, a scenario which, to characterize in logic operators, corresponds to not P and not Q (not P or Q). Given the independence of P and Q, we multiply P’s probability of failure with Q’s probability of failure to get the probability that the parallel system fails as a whole. System failure illustrates yet another situation, where logic operators are in use in our daily life.

  2. Hi Chris, great job on putting together such an informative post on the application between truth tables and logic operators with electrical circuits. I really liked how for each new logical gate you introduced that you made sure to connect the switches back to the truth values of P and Q. I also liked how you drew close-ups of the logical gates to clearly illustrate how the switches work and how power is able to flow through during true conditions. I do have a question after reading your post. Of the basic logical operators that we have learned in class, I was wondering is it possible to create unique electrical gates just for the truth values of an implication and biconditional statement without using a combination of the and, or, not gates? In other words, is it possible to create a diagram of a gate that mimics an implication or biconditional without having any and, or, not gates inside of the diagram?

Leave a Reply

Your email address will not be published. Required fields are marked *