#15) What Is a Logic Gate?
Hello, and welcome back to "Always Be Better" with Mel Windham.
Today we're going to talk about logic gates, and guess what! This is our very first video that requires the viewing of an earlier one. Before you continue on, make sure you've already watched this introduction to logic. [LOL -- I point in the wrong direction because I didn't realize that YouTube deactivated Annotations for new videos] Just click this link, watch it, and come back here for Part 2. I'll give you five seconds and then we're diving in.
Here we go. What's a logic gate? The best way to explain is to show you.
Let's say I'm at home, working hard, and my kids want me to go on a walk with them. I look down at my bare feet and make a deal with my kids. "If you bring me my shoes AND my socks, then I'll go on a walk."
Let's graph this out ...
Shoes | |||
0 | 1 | ||
Socks | 0 | ||
1 |
Shoes are up at the top: 1 means they bring me my shoes, and 0 means they don't.
Socks are at the left: 1 means they bring me my socks, and 0 means they don't. Just as I warned before, I'm using 1 for TRUE and 0 for FALSE -- mainly because it's easier to see, and it reinforces the idea of thinking like a computer.
So, Question #1: if my kids leave me alone and don't bring me anything, am I going on a walk? Of course not. It's not the deal I promised. To graph this result, I find where Shoes = 0 and where Socks = 0 and place a 0 where the two meet in the table ... like this...
Shoes | |||
0 | 1 | ||
Socks | 0 | 0 | |
1 |
This red 0 means I'm not going on a walk.
Question #2: if they bring me my shoes but not my socks, that's not going to work -- right? Who wears shoes without sock? Other than CEOs? I'm going to place a 0 where Shoes--1 and Socks--0 meet.
Shoes | |||
0 | 1 | ||
Socks | 0 | 0 | 0 |
1 |
And you see where this is going -- if my kids flip flop and give me my socks but not my shoes, I'm not going on a walk, so a 0 goes here ...
Shoes | |||
0 | 1 | ||
Socks | 0 | 0 | 0 |
1 | 0 |
And finally -- if they bring me both my shoes and socks, then I'm happy. We're going on a walk, and I mark this with a 1 ...
Shoes | |||
0 | 1 | ||
Socks | 0 | 0 | 0 |
1 | 0 | 1 |
This is an example of an AND gate. Remember, I used the word AND in my promise: Bring me my shoes AND my socks, and I will go on a walk.
So, why do I keep calling this a gate? It comes from the field of electronics. Check this out.
At the top is a battery, providing the charge. To the right is a lightbulb, which will light up if there's a current. And notice the dotted box -- that's our AND gate. In order to light the lightbulb, the electricity must pass through this gate. Inside it are two open switches: One for "Shoes" and one for "Socks". If I close "Shoes", nothing happens, because "Socks" is still open. But when I also close "Socks", it closes the loop and the lightbulb lights up. It takes both to light a lightbulb!
So, what does this have to do with logic? We'll learn soon enough. At the lowest level, there's absolutely no difference between computer logic and classical logic, and I think this approach will help many understand this better.
So going back to our table, let's take away the Shoes and Socks, and replace them with A and B, and you can see the AND gate in its purest form:
AND | ||
A=0 | A=1 | |
B=0 | 0 | 0 |
B=1 | 0 | 1 |
And now A and B can mean anything we want. Maybe the two choices are the aquarium and the beach. If we did this, then I would tell my kids, "We got to make it worth my while. If we see both the aquarium AND the beach, then I'll go on a walk."
Another popular gate is the OR gate. It works like this -- "I'll go on a walk if we see either the aquarium OR the beach -- or both. I'll let you decide." So, we can fill out the gate like we did before. I'll give you five seconds to study this table, and compare with the AND gate. Feel free to pause if you need more time.
OR | ||
A=0 | A=1 | |
B=0 | 0 | 1 |
B=1 | 1 | 1 |
Let's say instead, I want to see something, but I don't have much time. We can see one attraction but not both. This type of thing happens all the time in real life. You have two choices, and you can't choose both. This is called the Exclusive OR gate, abbreviated as XOR, and it looks like this ...
XOR | ||
A=0 | A=1 | |
B=0 | 0 | 1 |
B=1 | 1 | 0 |
And another possibility ... maybe I'm just tired of working, and I don't care which attractions we see -- we could see none, or one, or both. We can call this the TRUE gate ...
TRUE | ||
A=0 | A=1 | |
B=0 | 1 | 1 |
B=1 | 1 | 1 |
Now we're up to four gates. These are all important, but they're not the only gates. We can get four more right off the bat by applying the NOT function to each gate, flipping all 1's to 0's and 0's to 1's, and we get these possibilities:
~AND | ~OR (NOR) | ~XOR | FALSE | |||||||||||
A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | |||||||
B=0 | 1 | 1 | B=0 | 1 | 0 | B=0 | 1 | 0 | B=0 | 0 | 0 | |||
B=1 | 1 | 0 | B=1 | 0 | 0 | B=1 | 0 | 1 | B=1 | 0 | 0 |
Not AND means: I don't have time to do both, but we can do none or one attraction.
Not OR (also called NOR) means: I don't want to see the aquarium NOR the beach. I'll only go on a walk if we see neither. I have just enough time for a walk and nothing else.
Not XOR is perhaps the most convoluted: I'll do zero or two attractions, but not one.
And the FALSE gate says simply: Forget it. I don't have time to walk -- at all. Go to your rooms!
I'll give you five seconds to study these eight gates and then I'll show you the rest. We're almost done.
These next four gates are what I call the picky gates ...
A | B | ONLY A | ONLY B | |||||||||||
A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | |||||||
B=0 | 0 | 1 | B=0 | 0 | 0 | B=0 | 0 | 1 | B=0 | 0 | 0 | |||
B=1 | 0 | 1 | B=1 | 1 | 1 | B=1 | 0 | 0 | B=1 | 1 | 0 |
The A gate means: I really want to see the aquarium, and the beach is optional.
The B gate is the mirror: I really want to see the beach, and the aquarium is optional.
ONLY A means: I only want to see the aquarium, and not the beach -- it has scorpions.
ONLY B means: I only want to see the beach, and not the aquarium -- it's too expensive.
And I'll go ahead and give you the NOT versions as well ...
~A | ~B | A -> B | B -> A | |||||||||||
A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | A=0 | A=1 | |||||||
B=0 | 1 | 0 | B=0 | 1 | 1 | B=0 | 1 | 0 | B=0 | 1 | 1 | |||
B=1 | 1 | 0 | B=1 | 0 | 0 | B=1 | 1 | 1 | B=1 | 0 | 1 |
NOT A means: I'm not going to the aquarium, but we could do the beach (or not).
NOT B means: I'm not going to the beach, but we could do the aquarium (or not).
And the last two are kind of strange. You may recognize the IF / THEN symbol.
Think of it this way. A -> B means: "IF we go to the aquarium, THEN we also have to go to the beach, else I'm not going on a walk." Since these will take more time to explain, I'm going to save these last two for our next lesson on logic. To give you a quick hint, the only way for an IF / THEN to be false is if you find a counterexample.
For now, I'll just bring back all the gates and say: Congratulations! We made it through all 16 logic gates! There ain't no more. I'll give you five seconds to consider them all before we wrap up.
I know -- I threw a lot at you, but it'll make more sense in our next lesson. These gates may seem a lot like abstract math, but they all relate to real life as well. In fact, understanding these gates is vital to understanding logic and to use the tools that we're going to learn later. Eventually this will help us to have very engaging and productive discussions in regards to politics, economics, belief systems, and so on.
For this next week, I'd like you to think about these 16 logic gates and see if you can find them in real life. When you have to choose a show to watch -- it's the Exclusive OR gate. Whenever there are two or more requirements to be satisfied, that's an AND gate. If someone ignores you completely, it could be a TRUE or FALSE gate. Just keep an eye out and take note of what you see.
In our next logic lesson we'll come back and see how we can use these gates in reasoning things out. Thank you for watching, and remember -- we can "Always Be Better."
Comments
Post a Comment