 Hello, and welcome to the first in a series of screencasts on relations. The relation is a mathematical concept that underlies actually a lot of the technology we use today, including social networking software like Facebook or Twitter. Let's develop the idea of a relation by looking at a very small social network. This network consists of five people, Alice, Bob, Chuck, Dave, and Ed. They're on a social network that allows one person to quote unquote follow the posts of another. If one person follows another, then the person being followed does not have to follow the other person back. So let's suppose that the network currently looks like this. Alice follows Bob, Chuck, and Ed. Bob follows Alice, Dave, and Ed. Chuck doesn't follow anybody, he's like a celebrity. Dave follows Alice, Bob, Chuck, and Ed. And finally, Ed follows Dave. So we have a tangled web of connections here. And if you think about a real person's Twitter stream or Facebook network, it gets hugely more tangled than this in real life. So you might ask, how does the software that manages this network keep track of who is connected to whom in the network? Well, one way could be to use ordered pairs. The social network in this sense would be a set of ordered pairs and we'll put the f pair x, y in the set if x follows y. So for example, this small social network could be represented as the following set of ordered pairs. Alice, Bob, Alice, Chuck, Alice, Ed, Bob, Alice, Bob, Dave, Bob, Ed, Dave, Alice, Dave, Bob, Dave, Chuck, Dave, Ed, and finally Ed, Dave. If Bob one day decided to follow Chuck, then we just have to append the pair Bob, Chuck to the set. Or if Bob unfollowed Dave, we would have to remove the pair Bob, Dave from the set. So what we have here is a set of ordered pairs. If we let P be the set consisting of people in this network, that would be Alice, Bob, Chuck, Dave, and Ed. Then our social network really in this representation is a subset of the Cartesian product P cross P. And in fact it consists of all the ordered pairs x, y and P cross P such that x follows y. So if you think this sounds like our ordered pair representation of a function that we saw in earlier screencasts, then you'd be on the right track. However, notice that our social network here is definitely not a function because there's lots of instances where a single person quote unquote maps to several others like Dave here who maps to four different people. But that doesn't make this set theoretic model of a social network a bad idea. It's just not a function, but that's okay. It's an accurate and pretty handy way of representing and keeping track of relationships between people. So since this is a handy way of keeping track of relationships, it's no surprise that what we've described here is called a relation. Here's the formal definition, although there's really not much to it. Let's let A and B be sets. Then we're going to define a relation from A to B to be just a subset of A cross B. And sometimes like with our social network, the sets A and B are the same. In that case, if we have a relation from a set to itself, which is just a subset of A cross A, we call that just a relation on A. So in other words, a relation from A to B is just a collection of ordered pairs where the first coordinate belongs to A and the second coordinate belongs to B. There may not be all of A cross B, but it's just a subset of ordered pairs from A cross B. This minimalist definition here is really actually useful because relations can model all sorts of interesting and useful things due to the lack of rules that are in the definition. A couple of pieces of terminology before we look at more examples. If R is a relation from A to B, then we say that A is the domain of the relation and B is the range. There is no concept of a co-domain for a relation. We only speak of domain and range. So here are a couple of other useful examples of relations besides social networks. Let's consider the relation R from the set of all words in the English language, which we're going to call W here, to the natural numbers. Defined by R is the set of all ordered pairs in W cross N, such that the length of the first coordinate equals the second coordinate. So every pair in this relation here is an ordered pair where the first coordinate is a word and the second coordinate is a natural number. What are some examples of pairs that belong to this relation? Well, one example is dog comma three because the length of the word dog is three. Another would be cat comma three and another would be Michigan comma eight. What this relation really is, is like a very simple database where you could look up a word and it tells you how long the word is. An example of a pair that would not belong to this relation would be dog comma two because the length of the word dog is not equal to two. You're actually, what we have here is a function, not just a relation. This is not only a set of ordered pairs. It's a set of ordered pairs such that if the first coordinates of any two pairs are the same, then the second coordinates must also be the same. So there's no quote unquote input splitting. And every word in W is actually paired off with some natural number. So what this example illustrates is that every function is a relation, but not every relation is a function. Here's another example of a relation. This time it's a relation from the set of real numbers to itself. So we're, it is a relation on the set of real numbers. A pair x comma y of real numbers belongs to this relation if and only if x is less than or equal to y. So for example, two comma five is in the set r and so is two comma ten. And that automatically tells you that this relation is not a function because two is related to two different things. Now on the other hand, five comma two would not be in this relation because, of course, five is not less than or equal to two. However, five comma five would be in that relation because five is less than or equal to five. So again, this relation is just a set of ordered pairs from r cross r. Not the entire set of ordered pairs in r cross r, but just a subset that satisfies a certain condition. So let's see how well you're getting the concept of relation with a concept check. Let's let w be the set of all English words that we saw earlier. And define a relation r on w as follows. r is a set of all pairs in English words, w one comma w two, such that w one differs from w two by one letter or less. This would be an important relation if you are thinking about spell check software or language recognition. Which of the following pairs belongs to r? Select all the ones that apply and come back when you're ready. So the answer here is all the pairs but the last one belong to this relation. Because for each of the other pairs, the words in the pairs are either equal or else they differ by only one letter. But the last pair differs by two letters so it does not belong to the relation. So that is the basic concept behind relations. Thanks for watching.