Boolean Logic & Logic Gates: Crash Course Computer Science #3 — Transcript
Full transcript
- 0:03Hi, I’m Carrie Anne and welcome to Crash Course Computer Science!
- 0:06Today we start our journey up the ladder of abstraction, where we leave behind the simplicity
- 0:10of being able to see every switch and gear, but gain the ability to assemble increasingly
- 0:15complex systems.
- 0:16INTRO
- 0:25Last episode, we talked about how computers evolved from electromechanical devices, that
- 0:30often had decimal representations of numbers – like those represented by teeth on a gear
- 0:35– to electronic computers with transistors that can turn the flow of electricity on or off.
- 0:39And fortunately, even with just two states of electricity, we can represent important information.
- 0:44We call this representation Binary -- which literally means “of two states”, in the
- 0:48same way a bicycle has two wheels or a biped has two legs.
- 0:52You might think two states isn’t a lot to work with, and you’d be right!
- 0:55But, it’s exactly what you need for representing the values “true” and “false”.
- 0:59In computers, an “on” state, when electricity is flowing, represents true.
- 1:03The off state, no electricity flowing, represents false.
- 1:06We can also write binary as 1’s and 0’s instead of true’s and false’s – they
- 1:10are just different expressions of the same signal – but we’ll talk more about that in the next episode.
- 1:15Now it is actually possible to use transistors for more than just turning electrical current
- 1:19on and off, and to allow for different levels of current.
- 1:22Some early electronic computers were ternary, that's three states, and even quinary, using 5 states.
- 1:27The problem is, the more intermediate states there are, the harder it is to keep them all
- 1:31seperate -- if your smartphone battery starts running low or there’s electrical noise
- 1:35because someone's running a microwave nearby, the signals can get mixed up... and this problem
- 1:39only gets worse with transistors changing states millions of times per second!
- 1:43So, placing two signals as far apart as possible - using just ‘on and off’ - gives us the
- 1:48most distinct signal to minimize these issues.
- 1:51Another reason computers use binary is that an entire branch of mathematics already existed
- 1:55that dealt exclusively with true and false values.
- 1:58And it had figured out all of the necessary rules and operations for manipulating them.
- 2:01It's called Boolean Algebra!
- 2:03George Boole, from which Boolean Algebra later got its name, was a self-taught English mathematician in the 1800s.
- 2:09He was interested in representing logical statements that went “under, over, and beyond”
- 2:14Aristotle’s approach to logic, which was, unsurprisingly, grounded in philosophy.
- 2:18Boole’s approach allowed truth to be systematically and formally proven, through logic equations
- 2:22which he introduced in his first book, “The Mathematical Analysis of Logic” in 1847.
- 2:27In “regular” algebra -- the type you probably learned in high school -- the values of variables
- 2:31are numbers, and operations on those numbers are things like addition and multiplication.
- 2:36But in Boolean Algebra, the values of variables are true and false, and the operations are logical.
- 2:41There are three fundamental operations in Boolean Algebra: a NOT, an AND, and an OR operation.
- 2:47And these operations turn out to be really useful so we’re going to look at them individually.
- 2:51A NOT takes a single boolean value, either true or false, and negates it.
- 2:55It flips true to false, and false to true.
- 2:58We can write out a little logic table that shows the original value under Input, and
- 3:01the outcome after applying the operation under Output.
- 3:04Now here’s the cool part -- we can easily build boolean logic out of transistors.
- 3:08As we discussed last episode, transistors are really just little electrically controlled switches.
- 3:13They have three wires: two electrodes and one control wire.
- 3:16When you apply electricity to the control wire, it lets current flow through from one
- 3:21electrode, through the transistor, to the other electrode.
- 3:24This is a lot like a spigot on a pipe -- open the tap, water flows, close the tap, water shuts off.
- 3:29You can think of the control wire as an input, and the wire coming from the bottom electrode as the output.
- 3:34So with a single transistor, we have one input and one output.
- 3:38If we turn the input on, the output is also on because the current can flow through it.
- 3:42If we turn the input off, the output is also off and the current can no longer pass through.
- 3:47Or in boolean terms, when the input is true, the output is true.
- 3:50And when the input is false, the output is also false.
- 3:53Which again we can show on a logic table.
- 3:55This isn’t a very exciting circuit though because its not doing anything -- the input
- 3:58and output are the same.
- 4:00But, we can modify this circuit just a little bit to create a NOT.
- 4:03Instead of having the output wire at the end of the transistor, we can move it before.
- 4:07If we turn the input on, the transistor allows current to pass through it to the “ground”,
- 4:11and the output wire won’t receive that current - so it will be off.
- 4:14In our water metaphor grounding would be like if all the water in your house was flowing
- 4:17out of a huge hose so there wasn’t any water pressure left for your shower.
- 4:21So in this case if the input is on, output is off.
- 4:24When we turn off the transistor, though, current is prevented from flowing down it to the
- 4:28ground, so instead, current flows through the output wire.
- 4:31So the input will be off and the output will be on.
- 4:34And this matches our logic table for NOT, so congrats, we just built a circuit that computes NOT!
- 4:38We call them NOT gates - we call them gates because they’re controlling the path of our current.
- 4:43The AND Boolean operation takes two inputs, but still has a single output.
- 4:48In this case the output is only true if both inputs are true.
- 4:51Think about it like telling the truth.
- 4:53You’re only being completely honest if you don’t lie even a little.
- 4:56For example, let’s take the statement, “My name is Carrie Anne AND I’m wearing a blue dress".
- 5:01Both of those facts are true, so the whole statement is true.
- 5:03But if I said, “My name is Carrie Anne AND I’m wearing pants” that would be false,
- 5:08because I’m not wearing pants.
- 5:09Or trousers.
- 5:10If you’re in England.
- 5:11The Carrie Anne part is true, but a true AND a false, is still false.
- 5:15If I were to reverse that statement it would still obviously be false, and if I were to
- 5:19tell you two complete lies that is also false, and again we can write all of these combinations
- 5:24out in a table.
- 5:25To build an AND gate, we need two transistors connected together so we have our two inputs
- 5:30and one output.
- 5:31If we turn on just transistor A, current won’t flow because the current is stopped by transistor B.
- 5:36Alternatively, if transistor B is on, but the transistor A is off,
- 5:40the same thing, the current can’t get through.
- 5:41Only if transistor A AND transistor B are on does the output wire have current.
- 5:46The last boolean operation is OR -- where only one input has to be true for the output to be true.
- 5:51For example, my name is Margaret Hamilton OR I’m wearing a blue dress.
- 5:55This is a true statement because although I’m not Margaret Hamilton unfortunately,
- 5:59I am wearing a blue dress, so the overall statement is true.
- 6:02An OR statement is also true if both facts are true.
- 6:06The only time an OR statement is false is if both inputs are false.
- 6:09Building an OR gate from transistors needs a few extra wires.
- 6:12Instead of having two transistors in series -- one after the other -- we have them in parallel.
- 6:17We run wires from the current source to both transistors.
- 6:20We use this little arc to note that the wires jump over one another and aren’t connected,
- 6:24even though they look like they cross.
- 6:26If both transistors are turned off, the current is prevented from flowing to the output,
- 6:30so the output is also off.
- 6:32Now, if we turn on just Transistor A, current can flow to the output.
- 6:36Same thing if transistor A is off, but Transistor B in on.
- 6:39Basically if A OR B is on, the output is also on.
- 6:43Also, if both transistors are on, the output is still on.
- 6:47Ok, now that we’ve got NOT, AND, and OR gates, and we can leave behind the constituent
- 6:52transistors and move up a layer of abstraction.
- 6:54The standard engineers use for these gates are a triangle with a dot for a NOT,
- 6:58a D for the AND, and a spaceship for the OR.
- 7:01Those aren’t the official names, but that's howI like to think of them.
- 7:03Representing them and thinking about them this way allows us to build even bigger components
- 7:07while keeping the overall complexity relatively the same - just remember that that mess of
- 7:11transistors and wires is still there.
- 7:13For example, another useful boolean operation in computation is called an Exclusive OR - or XOR for short.
- 7:20XOR is like a regular OR, but with one difference: if both inputs are true, the XOR is false.
- 7:26The only time an XOR is true is when one input is true and the other input is false.
- 7:31It’s like when you go out to dinner and your meal comes with a side salad OR a soup
- 7:35– sadly, you can’t have both!
- 7:36And building this from transistors is pretty confusing, but we can show how an XOR is created
- 7:41from our three basic boolean gates.
- 7:43We know we have two inputs again -- A and B -- and one output.
- 7:46Let’s start with an OR gate, since the logic table looks almost identical to an OR.
- 7:50There’s only one problem - when A and B are true, the logic is different from OR,
- 7:55and we need to output “false”.
- 7:56To do this we need to add some additional gates.
- 7:59If we add an AND gate, and the input is true and true, the output will be true.
- 8:03This isn’t what we want.
- 8:04But if we add a NOT immediately after this will flip it to false.
- 8:08Okay, now if we add a final AND gate and send it that value along with the output of our
- 8:13original OR gate, the AND will take in “false” and “true”, and since AND needs both values
- 8:19to be true, its output is false.
- 8:21That’s the first row of our logic table.
- 8:22If we work through the remaining input combinations, we can see this boolean logic
- 8:26circuit does implement an Exclusive OR.
- 8:28And XOR turns out to be a very useful component, and we’ll get to it in another episode,
- 8:33so useful in fact engineers gave it its own symbol too -- an OR gate with a smile :)
- 8:38But most importantly, we can now put XOR into our metaphorical toolbox and not have to worry
- 8:42about the individual logic gates that make it up, or the transistors that make up those gates,
- 8:46or how electrons are flowing through a semiconductor.
- 8:49Moving up another layer of abstraction.
- 8:51When computer engineers are designing processors, they rarely work at the transistor level,
- 8:55and instead work with much larger blocks, like logic gates, and even larger components
- 8:59made up of logic gates, which we’ll discuss in future episodes.
- 9:02And even if you are a professional computer programmer, it’s not often that you think
- 9:05about how the logic that you are programming is actually implemented in the physical world
- 9:09by these teeny tiny components.
- 9:11We’ve also moved from thinking about raw electrical signals to our first representation
- 9:15of data - true and false - and we’ve even gotten a little taste of computation.
- 9:20With just the logic gates in this episode, we could build a machine that evaluates complex logic statements,
- 9:25like if “Name is John Green AND after 5pm OR is Weekend
- 9:29AND near Pizza Hut”, then “John will want pizza” equals true.
- 9:33And with that, I'm starving, I'll see you next week.
About this transcript
This page contains the full transcript of Boolean Logic & Logic Gates: Crash Course Computer Science #3 by CrashCourse, generated from the public captions YouTube serves with the video. The transcript has 2,019 words across 155 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.