 Welcome to the screencast, which is the first in a series on sets. In this screencast, we're going to look at sets and operations that we can perform on them. To motivate the ideas we're going to see here, let's consider a situation that most of us are quite familiar with that's updating our status on a social network. Now, it used to be that in social networks like Facebook, if you updated your status to say something like, I'm having lunch, it would go out to all the people to whom we were connected in the network, whether they wanted that update or not. Well, more recently, people have been realizing that while it's nice to have all the people we're connected to together in the same social network, it's not always the case that all those people need to see every status update that I have. For example, my family members might want to see those photos of all my kids that I upload, but people I know through work might not. So recently, social networks have introduced this feature where you can assign people you know to different groups and so you can target your status update to the group. So for example, in one of my social networks, I have a group for education people, I have a group for technology people, one for family members, one for college friends, one for high school friends, one for coworkers, one for runners, and one that I call VIPs, who are my closest confidants in the network. And sometimes there are people who are in multiple groups at the same time. For example, my nephew Clark runs Ultramarathons as a hobby, which is beyond my comprehension, but he's both a family member and a runner, so he's in both groups at the same time. So if I want to send a status update, I can send it to everybody. I can send it to everybody just in one group, or I can send them to a combination of groups. Now somehow the software that runs this social network needs to know how to handle a status update whose audience is not totally obvious. For example, say I want to send a status update to all the people who are the VIPs on my coworkers list, or people who are family but not runners. So if I had a large list of contacts in the network, I'd like to have the software automate that process rather than having me go through every person on the network and decide one by one who gets the status update and who doesn't. So how do we do that? So the answer lies in the concept of the set. In mathematics, sets are a basic object that we always seem to work with but don't often focus upon. So in this chapter, we're going to turn our focus to understanding and working with these objects. Let's start with a simple definition. A set is just a well-defined collection of objects for us. And this leaves the particulars of sets wide open. We saw in chapter two that sets can contain all different kinds of objects. A set can even contain other sets as objects. And we have a couple of different notations for writing them called the roster notation and set builder notation. Now a group on my social network is a kind of set. And putting those sets together in certain ways is what we want to understand now by looking at certain operations that we perform on sets. So just like addition and multiplication are operations that we perform on numbers where we take one or two numbers and combine them in a certain way to produce a third number, sets have operations two that take one or two sets and produce a new set as output. So the first two operations we're going to consider are the intersection and union of two sets. These are defined as follows. Let's suppose we have two sets A and B, and we also have a universal set called U in which those two sets live. The intersection of two sets, and we use this sort of upside down U symbol to denote this, is a third set whose elements are all the elements that are in both A and B at the same time. And the union of two sets, and we'll use the U shaped symbol here for this, is the set of all elements that are in either A or B or both. Now note the use of the words and and or here, and that harkens back to our study of conjunctions and disjunctions earlier, and that's exactly what we want. So let's look at an example. Suppose my runner's group on my social network contains Clark, Damien, Alicia, and Dad. And my family group has Mom, Dad, Clark, Hudson, Caroline, and Sherry in it. Let's call the runner's group R and think of that as a set, and let's let the family set be called F. Then R intersect F, that would be the set of all people who in my network who are both runners and family members. And that would be the set consisting of just Clark and Dad. Note that this is a set, and so if we want to write it, we're going to use correct set notation, just use the roster notation here would be enough. And R union F would be the set of all people who are either runners or family members, possibly both. This would consist of Clark, Damien, Alicia, Dad, Mom, Hudson, Caroline, and Sherry. Some of these people are in both sets, but since we consider or to be inclusive, this is okay. Note that we do not double list people either. So although my dad is in both sets, for example, we're only going to list them once. So let's look at two more set operations that involve removing items from a set. The first is called the difference of two sets. And for this we're going to use the notation A minus B. The set difference of A and B here is the set consisting of all elements of A that are not elements of B. And we can say that using a conjunction here. So A minus B literally means I take A and then subtract or remove out all the elements of B that are in it. For example, using the runners and families group from earlier, R minus F would be the set of all people who are runners, but not family members. So here's R and to get the set difference R minus F, I'm just going to remove all the F people from the R list leaving the set of just Alicia and Damian. So let's pause for a moment and do a quick concept check. We've just seen what R minus F is. So what is F minus R? And here are the sets R and F. And let's see if you can come up with the right answer. Now the right answer here is C. To get this we're going to take the entire list of family members and just remove the runners from it. So we're going to X out Clark and X out my dad. And what you're left here is F minus R. Now notice that particularly R minus F is not the same set as F minus R. So the order of difference really matters here. Finally, let's look at the operation called the complement of a set. So unlike the other operations, this operation works on just one set at a time. So given a set A, we're going to define A complement and we use a little exponent C for this to be the set of all elements in the universal set that are just simply not in A. So A complement is all the elements that exist that are not members of A. So to use a different example from the social network, let's suppose the universal set is the set 1, 2, 3 all the way up to 10 and A is the set 2, 4, 8. Then A complement is the set 1, 3, 5, 6, 7, 9 and 10. These are all the elements of U that are not in A. Another way to say this would be to say that A complement is the difference U minus A. So one final concept check to see how well you're understanding this. So go back to the social network and let these sets represent some of my groups here. Let's suppose I wanted to post a status update that went only to the VIPs in my network but not to any family members and not to any coworkers. I don't know what kind of message that would be but let's suppose I wanna send it. What set should I use? And the answer here is E and let's think about why that is. We want to send the message to VIPs but minus a few people so we can definitely eliminate item C here. What I wanna subtract out from the set V are people who are family members as well as people who are coworkers. Now the word sort of and that you see or hear in that statement might make you think intersection here but in item D what we would be removing are people who are both coworkers and family members. So if I happen to be working with one of my family members that's who I would subtract out but I don't necessarily want that. I wanna subtract out somebody who is a coworker whether or not they are a family member and vice versa I wanna subtract out anyone who is a family member whether or not they are a coworker. So not necessarily people who are both. I wanna subtract out the union here. I wanna take all the VIPs and remove anybody who is either a coworker or a family member and so that's why E is correct here. So I hope that this shows you how you can use sets and operations on sets to do some things that have relevance to the real world and in the next video we're gonna see how these operations work if the sets unlike our social networks are infinite in size. Thanks for watching.