Lesson video

In progress...

Loading...

Welcome to this Oak National Academy lesson which is called "Boolean logic" and it's taken from the unit "Computer systems and data science." Thank you for joining me for this lesson today and I hope you enjoy learning along with me.

The outcome of today's lesson is I can describe how computers use Boolean logic and logic gates to make decisions.

Let's get started.

We have three keywords in this lesson, so the first keyword is Boolean.

And Boolean means an expression that evaluates to either true or false.

Then we have logic gate.

So a logic gate is an electronic component that carries out a logical operation.

And finally we have truth table.

And a truth table is a chart that shows all the possible ways a statement can be true or false.

So there's our three keywords.

Boolean, logic gate, and truth table.

There are two learning cycles in this lesson.

So the first learning cycle is to describe Boolean logic, and the second learning cycle is explain logic gates.

So we can now start with that first learning cycle, "Describe Boolean logic." The origin of the term comes from George Boole who was an English mathematician and logician, and he was born in 1815.

His work became one of the building blocks of modern computing, even though he himself never got to use a computer.

Boole was particularly interested in how humans think and have a reason.

And he believed that you could use maths to describe logic.

In 1847, he introduced Boolean logic, in which all expressions evaluate to either true or false.

So let's find out a little bit more about that.

Boolean logic is about making decisions using true or false values.

And it's this Boolean logic that provides the basic mathematical framework that's made modern computers possible.

Engineers would later go on to combine Boolean logic with electrical circuits to develop modern computers.

So the whole foundation of modern computing is built around Boolean logic, so the impact of his work can't be understated.

Without Boolean logic, we wouldn't have computers as we know them today.

Time for a true or false question.

George Boole used modern computers to develop Boolean logic.

Is that true or false? Correct, the answer is false.

Now can you explain why? And it's because modern computers were not invented during Boole's life, yet his work became one of the building blocks of modern computing, even though he never got to use a computer.

So let's dive into Boolean logic a bit further.

In Boolean logic, there are only ever two possible values.

So true, which is often represented as 1, and false, which is often represented as 0.

So in Boolean logic, these are the only two possible values, true represented as 1 and false represented as 0.

These are the same two values used in binary numbers, which is the language that computers understand.

So we've got a logic framework using 1 and 0 and then binary numbers which computers understand, which combine to make computers work.

Arithmetic operations, such as addition, operate using numbers.

So here we have 7 + x.

So the whole thing together is an arithmetic expression.

In this example, 7 is a constant, so that's a number.

The plus sign is the operator.

And then x is a variable, and that can be a number as well.

The result, the value of an arithmetic expression is also a number.

Logical operations operate in statements that are true or false.

So this time, instead of an arithmetic expression, we have a logical expression, so the whole thing together is the logical expression.

Then we have a statement, which is true or false.

An operator, which in this case is AND.

And then another statement, which is also true or false.

And together the result is the value of a logical expression, which is either true or false.

There are three basic Boolean operators.

So AND, which you've seen on the previous example, so AND is true if all conditions are true.

OR is true if at least one condition is true.

And NOT reverses the truth value.

I'm just gonna go through these again, these are really important for the rest of the lesson.

So AND is true if all conditions are true.

OR is true if at least one condition is true.

And NOT reverses the truth value.

So NOT reverses the value, so here we have an expression.

go out = NOT raining The whole thing together is the logical expression.

go out = NOT raining We have a statement, which is go out, which is true or false.

Then an operator, which in this case is NOT.

And then another statement, which is true or false.

So here we can see that if it's raining is false, then not raining will be true.

And if it's raining is true, then not raining is false.

And what this is saying in the form of an expression is that I will go out if it's not raining and I won't go out if it is raining.

The statement NOT A is true when A is false and vice versa.

So here we have an example of some electronic doors, so we've got a statement here which is open = motion AND activated So the first statement is a true or false statement, which is open.

Then we have another statement, which is true or false, so that's motion.

We have the operator, which is AND.

And finally a third statement, which is true or false.

And here's the table for this one.

So, if motion is false and activated is false, then the doors won't be open, so that's false.

There's no motion, there's no activation, the doors will not open.

If motion is false, so no motion, but activated is true, then open will still be false because one or the other is false, motion and activated.

Similarly, if motion is true and activated is false, then open will be false.

The only scenario in which open is true in this example is if motion is true, activated is true, and open is true.

All three need to be true.

So to sum this one up, the statement A AND B is true when both A and B are true.

So Laura has a question.

"What about if the left or right electric door was open?" So there's the left door, there's the right door.

So a door would be open if either the left or right door was open.

So the statement here would be open = left OR right So our first statement is open, that's true or false.

Then we have another statement, which is left, true or false.

Our operator, which is OR.

And our statement, which is right there, which is true or false.

So the table for this one is if both left or right were false, then open would be false.

Both doors would be closed, so open would be false.

If the left was false but the right was true, then the door is open, so that's true.

Similarly, if the left was true but the right was false, the door is still open and that's true.

And if both left and right are open, then the value of open is also true.

So let's sum that up as a statement.

The statement A OR B is true when at least one of A or B is true.

And it's also true if they're both true.

Time for a question.

Which Boolean operator reverses the truth value? Is it A, AND; B, OR; or C, NOT? Well then, the answer is NOT.

The Boolean operator NOT reverses the truth value.

Another question, the Boolean value true is often represented by the value.

Is it A, 1; B, 0; or C, 0.

5? Well done, the value true is often represented by the value 1.

Now match the statements to the description.

So match the Boolean operators with the correct meaning.

The three Boolean operators we have are the three we've introduced, AND, NOT, and OR.

And the three descriptions are only true if both conditions are true, true if at least one condition is true, and reverses the value, so that means true becomes false.

So let's go through the answers.

So AND is only true if both conditions are true.

NOT reverses the value, so true becomes false or false becomes true.

And OR is true if at least one condition is true.

Now time for the second part of your task.

In your own words, describe Boolean logic.

Okay, you could have written something like this.

So Boolean logic is a way of making decisions using only true or false values.

It uses simple rules like AND, OR, and NOT to check if conditions are met.

Computers use Boolean logic to help them decide what to do by following instructions or solving problems. Let's now move on to the second learning cycle, which is to explain logic gates.

In 1940, Claude Shannon proved that Boolean logical expressions and electrical circuits with switches are equivalent.

Shannon showed that on and off switches in an electrical circuit could represent true and false values, just like in Boolean logic.

There we have a picture of one switch which is off and one switch which is set to on.

So there's our off switch, so false equals 0.

And our on switch, which is true, equals 1.

So off is equivalent to false and 0, on is equivalent to true and 1.

The Boolean AND operator can be represented by two switches in a line, so here we have two switches and the AND value with those two switches.

So in this example, one switch is off and one switch is on.

So the switch on the left is open, which means off, and the switch on the right is closed, which means on.

Because one of them is off, then the whole circuit will be off.

So here you see the value of the first switch is off, which is 0.

And the value of the second switch is on, which is true or 1.

But because one of the circuits is off and we're using the AND operator, then the circuit will be off.

For it to be on, we'd need both switches to be on.

Here's another example.

So here we have two switches, but this time they're in parallel rather than in a line.

So this time we're going to look at the OR operator.

In this situation, the first switch at the top is off or false, the value is 0.

And the switch at the bottom is on or true with a value of 1.

In this example, the circuit will be on because one or other of the switches is on.

The circuit would also be on if both switches were on, or true or value 1.

If both switches were off or false or value 0, the circuit would be off.

Using electrical switches to implement Boolean logic is what led to the creation of logic gates.

A logic gate is the fundamental building block of digital circuits.

It's an electronic device that performs Boolean logic by taking one or more binary inputs and producing a single binary output.

There are three fundamental logic gates, and each logic gate can be represented as a symbol.

So first of all we have this one here, which is an AND logic gate.

The next one we have is an OR logic gate.

And finally we have a NOT logic gate.

I'm just gonna describe these to you in a little bit more detail as this is a really important concept for the rest of this lesson.

So the first one, the AND logic gate, has two inputs going into it and it's kind of like a half square, half semicircle shape with one output.

The second one looks a little bit like an arrowhead with two inputs going in and one input going out.

And then finally we have the NOT logic gate, which has one input, a triangle shape, then a small circle and one output.

So time for a true or false question.

Logic gates can be represented by symbols.

Is that true or false? Well done, as we've just seen, that's true, we can represent logic gates by using symbols.

So this builds on what I explained before, so the logic gates only have a single output.

Each the AND, the OR, and the NOT logic gate, they have one single output.

So there's our single outputs for each logic gate.

A NOT logic gate has one input, so there we see the one input into a NOT logic gate.

And the other logic gates, such as AND or OR, have two inputs.

So this one has two on the left for the AND logic gate and two on the right for the OR logic gate.

Laura has a question for Andeep.

"Did you know each logic gate has a truth table?" And Andeep says, "What's a truth table?" So let's find out.

A truth table is a simple way to show all the possible outcomes of a logic gate.

Truth tables are a clear and simple way to show exactly what a logic gate will output for every possible input.

So here we have an example of a basic truth table.

So we have the input being 0, the output being 1, or the input being 1 and the output being 0.

A truth table lists all the combinations of inputs like true or false and shows what the output result will be for each one.

The truth table below shows all the possible outcomes for a NOT gate.

So this is for a NOT gate, so if the input is 0, then the output will be 1.

If the input is 1, then the output will be 0.

And put simply, it means the input is not the same as the output.

Because we've only got two conditions, 1 or 0, that means if the input is 0, the output will be 1, or if the input is 1, the output is 0.

So that's the simplest example of a truth table.

The truth table below shows all the possible outcomes for an OR gate.

So this time, if input A or input B is 0, then the output will be 0.

If input A is 0 but input B is 1, then the output will be 1.

If input A is 1 but input B is 0, then the output will be 1.

And finally, if input A is 1 and input B is 1, the output will be 1.

So put simply, if either outputs or both outputs are 1, then the output will be 1.

If neither of the inputs is 1, they're both 0, then the output will be 0.

So that's an OR gate.

Now let's have a look at the outcomes for an AND gate.

So this time, if input A is 0 and input B is 0, the output will be 0.

If input A is 1 and input B is 0, the output will be 0.

And if input A is 1 and input B is 1, the output will be 1.

So for the output to be 1, both inputs need to be 1.

So both inputs need to be true for the output to be true.

Logic gates can be combined to create more complex circuits and logic.

Now we can have a look at a logic diagram for the Rock, Paper, Scissors game.

So we'll have a look at a couple of examples of how the game is represented in this diagram, so I'll just take you through what you can see here first of all on the screen.

So initially you've got the choice for Player 1, so rock, paper, or scissors, and the choice for Player 2, rock, paper, or scissors.

These are all 0 at the moment, so they haven't made a choice yet, so they're all false.

If we were to change them to true, then we'd change to number 1 and we'll do that in a second.

Then we've got in the middle we've got the process and that begins with six AND gates which give you every combination you can have of rock, paper, scissors for two players, so there's six different combinations.

And then each of the three combinations at the top and the bottom lead into an OR gate, so there's three inputs into that OR gate and one output.

And then in the middle we have the NOT gates here, so two NOT gates, one there and one there, and then another AND gate there.

And then we have finally on the right-hand side the three outcomes, so if Player 1 wins, tie, or Player 2 wins.

So let's start a simulation.

So first of all I'm gonna run it all the way through so that you can see what the outcome is.

So we're gonna have Player 1 choosing rock and Player 2 choosing paper.

Now we know in the game that paper beats rock, so you can see the Player 2 wins.

Let's have a look at how the simulation gets there.

So first of all, I'm just gonna turn paper to false, so we can just follow the lines through for rock.

So rock takes us into two of the AND gates, so the AND gate at the very top and then the AND gate here in the middle, so that one there and that one there.

So that's what rock will lead us to, two different AND gates.

And if I now turn on paper, you'll see that paper leads us to two AND gates as well, so this AND gate and this AND gate.

Now there's only one AND gate that's got two inputs, and it's this one here.

So this input is true, so it carries into this OR gate here.

So because we've got one true input into this OR gate, and it's an OR gate, it goes all the way through to Player 2 wins.

And because it's true here, it goes into a NOT gate, so it becomes false and stops there, okay? Similarly, this false line into this NOT gate becomes true.

But because this is an AND gate, we've got one true, one false, so it stops there.

So we can just prove that the model works by simulating a tie as well.

So we're gonna have rock and rock and you can see that this time everything ends at the AND gate in terms of trues, so everything from there on is false until they get to these two NOT gates where, because they're both false, they turn true, and we have the tie simulated.

So that's how the game Rock, Paper, Scissors can be simulated using AND, OR, and NOT gates.

If you'd like to try that logic diagram for yourself, go to oak.

link/rock-paper-scissors-logic So combining logic gates means computers can perform more advanced tasks, like making decisions and running programmes.

Modern computer processes contain billions of tiny logic gates that all work together at incredible speed.

So any computing device you use, like a mobile phone, a laptop, or an iPad, will have a processor like this.

It will be much smaller than the image you see there, probably about 1 centimetre squared, and will contain billions of tiny logic gates.

Logic gates are the building blocks of every digital device.

All computer hardware is built from logic circuits that understand only binary 0s and 1s.

Time for a question.

Which logic gate only ever has one input? Is it A, NOT; B, AND; or C, OR? Well done, it's NOT.

A NOT logic gate only ever has one input.

Time for a question.

The truth table below belongs to which logic gate? And in the truth table, we have input A is 0, input B is 0, and output is 0 on the first line.

On the second line, we have input A as 0, input B as 1, and the output as 1.

Third line, input A is 1, input B is 0, and the output is 1.

And on the fourth line, input A is 1, input B is 1, and the output is 1.

Does that truth table represent a NOT logic gate, an OR logic gate or an AND logic gate? Well done, it's an OR logic gate.

So if either A or input B or both are true, the output will be true.

Now a true or false question.

It's not possible to combine logic gates to create more complex circuits and logic.

Is that true or false? Okay, well done, that's false.

Can you explain your answer? And this is why.

Logic gates can be connected to create more complex circuits and logic.

Combining them means computers can perform more advanced tasks, like making decisions and running programmes.

Now time for your task, so match the logic gate names to the correct symbols.

And the three logic gate names we have are AND, NOT, and OR, so match those to the correct symbols on the right-hand side.

Okay, so the AND matches up to the symbol on the bottom, which is like the half rectangle, half semicircle, with two inputs and one output.

The OR logic gate is a bit like an arrowhead with two inputs and one output.

And the NOT logic gate is one input going into a triangle, then a small circle and one output.

And the second part of your task.

In your own words, explain how each of the three fundamental logic gates, AND, OR, and NOT, all work in their own way.

And you could have written something like this.

An AND gate only gives a true result if both inputs are true.

If even one input is false, then the answer is also false.

An OR gate gives a true result if at least one of its inputs is true.

It only gives a false result when both inputs are false.

And finally, a NOT gate only has one input and it flips it.

If the input is true, the output is false.

And if the input is false, the output is true.

Let's have a look at a summary of this lesson about Boolean logic.

In Boolean logic, there are only ever two possible truth values, true and false.

Logic gates are the fundamental building blocks of digital circuits and perform Boolean logic by taking one or more binary inputs and producing a single binary output.

Logic gates can be combined to create more complex circuits and logic.

Modern computer processes contain billions of tiny logic gates that all work together at incredible speed.

Thank you for joining me for this Oak National Academy lesson.

I hope you've enjoyed learning about Boolean Logic with me today, and I look forward to seeing you for more lessons in the future.