Okay. Welcome, everyone, to our first video. And this is gonna be on the basics of set theory. The point of this is really just to give us some very basic vocabulary that we're gonna agree on. We're gonna start with the idea of what is a set. We're then gonna go through a fancy word called cardinality, which is really just a fancy word for size. Then we're gonna go over two different ways to make sets from other sets called intersection and union. All this in the middle is gonna be a little bit of dry, a little bit of abstract. Fortunately, a little light at the end of the tunnel. Next video, we're gonna go over an example from medical testing. Where we're gonna see that just the simple ideas of size of a set and intersections and unions, already allow us to understand a real-world data science example. Okay, fine. Let's jump in. So, what is a set? As always in this course, I'd like to give you an example and then work over through the abstract details of what it is. So here's an example of a set. I'll write a capital letter A, an equal sign, an open bracket, and then some stuff inside the set. So here I'm gonna do one, two, minus three, seven. But let me give you another example of a set. Let's say that E is equal to open braces, the word apple, the word monkey, my co-author Daniel Egger, and close braces. Okay. So what can possibly be a general notion that meets these two ideas? Basically, a set is a collection of stuff. We should write that down. A set is a collection of things. It doesn't really matter what those things are. A little bit of vocabulary: a set is made up of elements. So in this example we have here, the set A is made up of four elements: the element one, the element two, the element minus three, the element seven. For this example on the right, the set E is made up of three elements: the element apple, the element monkey, and the element Daniel Egger. There's really no requirement of what those elements are; a set can really be made up of any things. We tend to use these braces to sort of contain the set. These are the things inside the set. A little bit of notation. When I write something like this: two and this funny little half E is in A, this symbol here stands for two is an element of A. For example, minus three is also in A. However, the number eight is not in A. We tend to write that by negating that – that little symbol there, that's what it means to be in there. Okay fine. The last little notion is the idea of cardinality or size. The definition of cardinality is just size of a set A is the number of elements in it. We usually use this notation, absolute value of A, looks like the absolute value symbol which we'll talk about later. So in this particular case, where A is equal to one, two, minus three, seven, the cardinality of A is four and the cardinality of E, in this case – I'll let you think about that for a little bit – just three. Okay. That's really all there is to cardinality. Fine. Let's jump to the next topic. Let me write three sets for you here. A is equal to one, two, minus three, seven – as you've seen before. Let's say B is equal to 2, 8, -3, 10, and D is equal to 5 and 10. Okay. Now you'll notice that of these three sets, they share some elements in common, some elements they don't share in common. There's two concepts called intersection and union which really allows to talk about those more rigorously. So first I'll just write down an example and we'll figure out the definition. A and then this funny symbol here B. This funny symbol is usually read intersect. This is the intersection of A and B. This is a set which is defined to be the set of elements which are in both A and in B, so the set of elements that A and B share in common. To work out what that is in this case, it's pretty easy to see that two is both in A and in B, and minus three is in both A and B and nothing else is. So A intersect B is equal to the set two, minus three. Okay, let's also work out for example the B intersect D is equal to the set of things which B and D have in common. And if we see, the only element in there is 10. Now here's a funny little trick question: let's work out A intersect D. A intersect D is defined to be the set of elements which both A and D have in common, and unfortunately there are none, so that set is empty. There's a special notation for that which is a zero with a cross through it. This is called the empty set. Hard to spell. And by convention, we always say that the cardinality of the empty set is zero – there's nothing in it. Okay. In this really simple example, let me give you a more complicated way of writing it which will prove fruitful later. Another way of writing A intersect B is to give you a recipe for computing it yourself. So the definition of A intersect B, instead of listing out the elements, I can list it this way: it's a set of x, I don't know what x is, but now I'm gonna give you conditions that x satisfies, that's what this little colon here means. The set of x such that x is in A and x is in B. This notation here is very, very important and we're gonna see it over and over again. So we have defined the elements of a set not by listing them explicitly, but by giving conditions they must satisfy to get in. You can almost think about it like membership in a club. This x are the people trying to get in the club, this colon is like the bouncer at the door of the club checking your ID and saying whether you get in or not. So imagine any x comes along, for example, two comes along and says, "Hey, I want to get into A intersect B. I hear this coll music in there." The bouncer asks, "Okay, let's check. Are you in A? Yup. And let's check, are you in B? Yup. Okay, you get in." On the other hand, suppose one comes along. One comes along and the bouncer checks, "Are you in A? Yup. Are you in B. Nope. And so you don't get in." That's the basic idea behind this definition. Okay, fine. Let's rewrite those sets and give you a different definition. So A is equal to one, two, minus three, seven; B is equal to 2, 8, -3, 10; and D is equal to 5, 10. The next idea we're gonna define here is the idea of the union. A and this funny upside down intersection symbol, A union B – this is read union. If intersection has the idea of and in here, union, you should think of as the idea of or. A union B is equal to the set of things which are in A or in B or in both. That's much more tolerant condition. So in this case, this will be one two minus three, seven. Two is already in A so I don't have to write it again. 8, 10. In bouncer-club notation, this is set of x such that x is in A or x is in B. Work at another notation, let's say A union D is equal to 1, 2, -3, 7, 5, and 10. Okay, so that concludes our first video. Just to recap what we've learned. You've learned what a set is, you've learned two funny ways to write it, one just by making some braces and putting some things inside the braces – thus gives you the elements of a set – and another way you've learned it is by this notation here which I'd like to whimsically call the bouncer-at-a-club notation, where we give you a variable x and we say what condition it has to satisfy to get in the set. You've also learned what the cardinality of a set is and you've learned how to turn two sets into intersections, which is what they have in common, and union, which sort of says what they all contain together. That concludes our video. In the next video, we'll see how to use this terminology to understand a real-world example.