Time
2 hours 57 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
Hello, everyone. And welcome back to intrude a python here on Cyberia. On demand I am your instructor is always Joe Perry. And today we're gonna begin Lesson one, programming basics logic.
00:11
In this lesson, we're gonna learn about Boolean logic and logical operations. Those operations are gonna be and or and not we're gonna learn to implement those logical operations in part, to buy, by learning with logical laws, the derived operations, most specifically X, or it's gonna be the one that really focus on.
00:29
So what is Boolean logic? I've used that term in a couple of these videos already, and it's important to understand sort of what it is and where it comes from. So Boolean Logic was published by a man named George Boole in the Book of the Mathematical Analysis of Logic, which is a page turner. I assure you, it's not. It's an incredibly dry and extremely boring book.
00:47
It was published in 18 47. And like most old things, that's terrible.
00:51
That was mean to say, but I'm gonna stick to it, stick to my guns, right. More seriously, though it was influenced by a Sanskrit philologist panini, I think that's how you pronounce that name. But honestly, my Sanskrit is rusty. I haven't taken it since high school. You know how it goes. Panini was a
01:08
a philologist is a person who is a grammarian. They study
01:11
the evolution in the design of languages and grammar and how they function. And he was quite possibly the first person to toe apply formal logic to the concept of linguistics and grammar, and over the course of creating that that work and over the course of sort of documenting that panini developed the concepts of sort of truth and falsehood that were then adopted.
01:30
Two
01:33
create Boolean algebra and early and logic,
01:36
so there are only two values in Boolean logic. It's not like normal math, where there's, you know, an infinite number of numbers and a raise and things like that. In Boolean Algebra and Boolean Logic, there are only two possible values one and zero,
01:47
and then there are only three possible operations there's and which is represented in formal logic. By a period and usually in shorthand or informal or programming, it's represented an ampersand
01:57
there's or which is represented by the plus sign or by the pipe. That's the straight line kind of up and down. Usually it's gonna be on the same place as your forward slash
02:07
on then, not which is usually represented by a tilled. So those were the only two values in the only three fundamental operations of Boolean logic. But from those very simple concepts were actually able to derive all of math, all of modern computer science, all touring complete machines and a pretty substantial chunk of mathematics. Now
02:25
there is, you know, for those who are really excited about the very modern, most modern technology,
02:30
quantum computing does kind of play with that a little bit and introduces relativistic probabilistic states. But fortunately, this is an intruder python video and not a quantum computing video. So save your hate mail for when I earn it later.
02:44
So in this lesson, we're gonna spend a lot of time on truth tables. And if you never had the joy of going through a CS 101 class
02:51
A truth table is exactly what you see in front of you. It's a table of some number of values and statements, which is used to represent every possible state of the equation. So you have In this case, we have two inputs and be and you'll see those use pretty often
03:07
on dhe with and B. We represent every possible combination of those two Boolean factors or 1,000,000,000 values. True or false. So they were, by the way, in computer science, when you talk about true and false, that's the ones and zeros of binary. Binary is an implementation of that Buckley and
03:25
logic. So we're gonna use one and zero instead of true and false in most of these places. Don't let that
03:30
Don't let that trip you up too much.
03:32
So you can see we have two ones and two zeroes under A. If we just had a in this table, it would just be two lines of one and zero. But because we have two factors, we have to represent every possible combination. And for those of you who know binary and understand how to read binary, you know that with two digits you're capable of representing four numbers
03:51
012 and three
03:53
and a useful sort of equation when you're building your truth tables is however many inputs you have, it will be that power of two number of rose which is to say, well, that that part of the number of possible combinations so that many rose Which is to say, for example, if you have three inputs is gonna be 80. If you have four, it'll be 16. You have five. It'll be 32 sort of on and on and on and on.
04:14
If you have five inputs, I generally don't recommend building a single truth table.
04:18
We're not gonna deal with any truth table's larger than three inputs and two or three statements at a time. Your statement is gonna have the same number of roses, your input. And that's just going to be whatever equation you're doing. And we'll see that it will make a little more sense, I think, in the next couple of slides. Well, kind of see that play out your statement is gonna be just all of the solutions with those inputs.
04:38
So it's an example. Here we have the first logical operation. We see that we have true and false, represented with and be the same way we do in this previous slide with ones and zeroes. And we see that and evaluates to true that is, and evaluates toe one if and only if so, only in the case
04:55
that all of its input values are also true or one.
04:59
So on this table you can see that on our first row A is one, and B is once that's representing the binary number three. The end A A and B we're gonna represent here
05:10
is one. Because of the fact that both of the inputs were true, the output of end is true. Pretty straightforward. The next row we have a is one which which helps us to evaluate this, but be a zero now, I said again, I'll say again and evaluates to true on Lee in the case that all input values are true,
05:29
Which means that with me being zero
05:30
A A and B is also zero. As you could see on the next row, a zero B is one still have a zero in it, and on the final one, of course, both of them are zero there. Four and a zero. Ah, useful shorthand is that, generally speaking, if you end all of your inputs together in a truth table, you're generally only ever going to have one row evaluate. Too true,
05:50
it's not 100% the case. There are complex inputs that can mess with that.
05:56
But as a basic rule, you can generally trust that
06:00
so or oh, and I want to mention real fast. I always kept it and is often referred to as the logical conjunction in formal logic classes. So if you hear that, that's what that's referencing
06:10
now or logical disjunction or is similar to and in that it evaluates to true. Based on whether or not an input is true, It's different in the sense that if any of the inputs toe or are true or we'll evaluate to true so sort of not exactly the inverse of end, but to some extent it kind of feels that way. And it kind of looks that way on the truth table as well.
06:29
For example, on our first row we have A and B, both equaling one. Now it doesn't matter if both of them are true,
06:34
so long as one of them is true.
06:36
So a or B evaluates to true. On the next drill, we see that a is one and B a zero now with, and you'll remember that that evaluated to zero because one of the inputs was false. However, because one of the inputs is true for or it evaluates to true
06:49
the next rope. Same thing with B being true instead of a and then the final road because none of it's inputs are true or we'll evaluate the false.
06:58
The third and final fundamental logical operation of Boolean logic is not or the logical inversion
07:05
not evaluates the true if, and only if only in the case that its input is false. NAND is generally used for single inputs or it is used for the results of an equation. So, for example, you can see here that I have manned and Norwich to very commonly used gates in logic. Gates and operations are differentiated in that a gate
07:25
is something that is actually physically construct a ble.
07:28
So even though the end or not, are the fundamental operations NAND and X, or are the two most commonly used fundamental gates physical gates of logic don't get wrapped around the axle that you aren't going to need to learn how to create a circuit board or a circuit diagram. Don't worry about that at all. In this class,
07:45
point is Nanda Nora to very commonly used logical operations which are derived from the three Fundamental.
07:50
Here. You can see that man, which is not end,
07:54
is going to be evaluated based on the input from. And so and we already established is gonna be 1000 Man is just the logical inversion of that. So we have 011 and one
08:05
very straightforward, very, very kind of, you know, easy to wrap your head around once you've seen it a couple of times A or B, you can probably guess because it's 1110 and Norris logical inversion of that. We're gonna have 000 and one.
08:20
So the next lesson we're gonna do some math, we're gonna jump in and really start learning about Cem Cem. Computational logic. Gonna learn about some fundamental laws of logic here. I've included a comic from the inimitable X K City. They're gonna be a lot of ex Casey's throughout this course because Randall Munroe is, frankly, a genius who has made the world a better place.
08:37
That said, Before we go on to the next lesson, we're gonna take a second. We're going to a knowledge check. We're gonna break these videos up a little for the next part of this lesson. We'll break these videos up a little bit. Just so you have time to digest it. Make sure you've learned the actual material. So which operation is the logical inversion of end? What is derived from the combination of and and not
08:58
the answer is AnAnd.
09:00
What are the two possible values of Boolean logic? There are only two
09:05
true and false.
09:07
What are the three fundamental operations of Boolean logic?
09:13
There are lots of possible operations. There are only three their fundamental and logical conjunction or logical disjunction and not logical inversion.
09:24
So summary in this video we cover basically what you just checked out on that last slide. The two possible values the three possible operations and discuss some of the derivations from those again. In the next video, we're gonna come back. We're gonna learn about the laws of logic or we're gonna apply them. Until then,
09:37
I am all I am, as always, thrilled to have you here and hope to see you back in our next video. I'm your instructor, Joe Perry, and this has been intruded Python

Up Next

Intro to Python

This is an introductory course on Python for cyber security, giving students the ability to understand the basics of the language, solve problems with scripts and identify useful Python modules.

Instructed By

Instructor Profile Image
Joe Perry
Senior Technical Instructor at FireEye, Inc
Instructor