1 00:00:00,704 --> 00:00:02,370 PROFESSOR: We've seen a lot of functions 2 00:00:02,370 --> 00:00:06,320 in introductory calculus-- trig functions, rational functions, 3 00:00:06,320 --> 00:00:08,900 exponentials, logs and so on. 4 00:00:08,900 --> 00:00:10,690 I don't know whether your calculus course 5 00:00:10,690 --> 00:00:14,250 has included a general discussion of functions. 6 00:00:14,250 --> 00:00:18,500 The old fashioned ones didn't, and we will go into that 7 00:00:18,500 --> 00:00:19,430 now in this segment. 8 00:00:19,430 --> 00:00:22,290 And we're going to be interpreting functions 9 00:00:22,290 --> 00:00:24,720 as a special case of binary relations. 10 00:00:24,720 --> 00:00:26,720 So let's just say what a binary relation is. 11 00:00:26,720 --> 00:00:29,170 A binary relation is a mathematical object 12 00:00:29,170 --> 00:00:31,420 that associates elements of one set 13 00:00:31,420 --> 00:00:34,270 called the domain with elements of another set 14 00:00:34,270 --> 00:00:35,440 called the codomain. 15 00:00:35,440 --> 00:00:38,380 And I'm going to give you a bunch of examples 16 00:00:38,380 --> 00:00:41,380 of binary relations in a short moment, 17 00:00:41,380 --> 00:00:44,788 but let's just talk about what they're for 18 00:00:44,788 --> 00:00:46,370 and what their role is. 19 00:00:46,370 --> 00:00:50,740 So they may be familiar to you as computer scientists 20 00:00:50,740 --> 00:00:53,980 if you've worked with any relational databases like SQL 21 00:00:53,980 --> 00:00:55,340 or MySQL. 22 00:00:55,340 --> 00:00:57,040 MySQL. 23 00:00:57,040 --> 00:00:59,440 And we'll see an example that indicates 24 00:00:59,440 --> 00:01:04,000 where the original ideas behind those relational databases 25 00:01:04,000 --> 00:01:05,450 came from. 26 00:01:05,450 --> 00:01:08,400 But even more fundamental, relations 27 00:01:08,400 --> 00:01:12,420 are one of the most basic mathematical abstractions right 28 00:01:12,420 --> 00:01:17,960 after sets, and they play a role everywhere. 29 00:01:17,960 --> 00:01:20,370 We're going to be looking in later lectures 30 00:01:20,370 --> 00:01:22,000 at special kinds of binary relations 31 00:01:22,000 --> 00:01:25,330 like equivalence relations and partial orders 32 00:01:25,330 --> 00:01:29,930 and numerical congruences. 33 00:01:29,930 --> 00:01:33,390 But today, we're going to set up the machinery 34 00:01:33,390 --> 00:01:36,600 to be using binary relations for counting, 35 00:01:36,600 --> 00:01:41,840 which will be another important application in this class. 36 00:01:41,840 --> 00:01:45,290 So let's look at an example. 37 00:01:45,290 --> 00:01:48,860 And I'm going to take one that's close to home-- the registered 38 00:01:48,860 --> 00:01:53,070 for relation, which is a relation between students-- 39 00:01:53,070 --> 00:01:55,890 that's going to be the domain, in this case, four 40 00:01:55,890 --> 00:02:03,510 students, Jason, Joan, Yihui, and Adam-- and four subjects. 41 00:02:03,510 --> 00:02:10,080 As a coincidence, 6.042, 003, 012, and 004. 42 00:02:10,080 --> 00:02:13,340 And the relation R is going to be indicated 43 00:02:13,340 --> 00:02:18,270 by arrows which show just which students are associated 44 00:02:18,270 --> 00:02:19,990 with which subjects, meaning that they're 45 00:02:19,990 --> 00:02:21,990 registered for that subject. 46 00:02:21,990 --> 00:02:25,650 So if we look at Jason, we can see 47 00:02:25,650 --> 00:02:31,420 that there's a particular arrow connecting Jason and 6.042. 48 00:02:31,420 --> 00:02:36,080 And what that tells us is that Jason is registered for 6.042. 49 00:02:36,080 --> 00:02:38,000 Now, there's a bunch of notations 50 00:02:38,000 --> 00:02:41,460 that are used with respect to binary relations. 51 00:02:41,460 --> 00:02:44,770 So let's look at some. 52 00:02:44,770 --> 00:02:46,540 One way to write it is if you think 53 00:02:46,540 --> 00:02:49,120 of the relation R as an equality sign 54 00:02:49,120 --> 00:02:51,380 or a less than sign, where it's normally 55 00:02:51,380 --> 00:02:53,820 written in the middle of the two things 56 00:02:53,820 --> 00:02:58,430 that it's connecting, as in this example-- Jason R 6.042. 57 00:02:58,430 --> 00:03:02,230 That would be called infix notation. 58 00:03:02,230 --> 00:03:04,925 Sometimes it's written as a binary predicate-- R 59 00:03:04,925 --> 00:03:07,770 of Jason comma 6.042. 60 00:03:07,770 --> 00:03:09,950 That would be kind of prefix notation 61 00:03:09,950 --> 00:03:13,830 where the relation or operator comes first. 62 00:03:13,830 --> 00:03:17,560 And then if you start being a little closer 63 00:03:17,560 --> 00:03:20,360 to the formal definition of what a binary relation is, 64 00:03:20,360 --> 00:03:24,160 you could say that the ordered pair Jason 6.042 65 00:03:24,160 --> 00:03:26,252 is a member of the relation. 66 00:03:26,252 --> 00:03:27,710 If you wanted to be really precise, 67 00:03:27,710 --> 00:03:29,660 you would say that it was a member 68 00:03:29,660 --> 00:03:31,950 of the graph of the relation. 69 00:03:31,950 --> 00:03:34,250 And I'll come back and elaborate further 70 00:03:34,250 --> 00:03:38,460 on what the graph of a relation is 71 00:03:38,460 --> 00:03:42,730 and what this ordered pairs businesses. 72 00:03:42,730 --> 00:03:45,390 But for now, just let's continue with this example. 73 00:03:45,390 --> 00:03:47,110 And a basic concept with relations 74 00:03:47,110 --> 00:03:50,530 is the idea of the image of a bunch of domain 75 00:03:50,530 --> 00:03:53,160 elements under the relation. 76 00:03:53,160 --> 00:03:56,290 So you can think of the relation as an operator 77 00:03:56,290 --> 00:03:59,250 that applies to domain elements or even sets 78 00:03:59,250 --> 00:04:00,700 of domain elements. 79 00:04:00,700 --> 00:04:05,250 So if I write R of Jason, that defines the subjects 80 00:04:05,250 --> 00:04:07,840 that Jason is registered for. 81 00:04:07,840 --> 00:04:11,770 So looking at the picture, R is not a function. 82 00:04:11,770 --> 00:04:15,040 So that there may be more than one subject, as is 83 00:04:15,040 --> 00:04:19,269 you'd expect for a student to be registered for multiple courses 84 00:04:19,269 --> 00:04:20,730 at MIT. 85 00:04:20,730 --> 00:04:26,020 So Jason in this diagram is registered for 6.042 and 6.012 86 00:04:26,020 --> 00:04:29,730 as indicated by the highlighted two connection 87 00:04:29,730 --> 00:04:33,030 arrows, which we've made red. 88 00:04:33,030 --> 00:04:35,770 Which means that R of Jason is that set 89 00:04:35,770 --> 00:04:39,720 of two courses that he's associated with 90 00:04:39,720 --> 00:04:41,540 or that are associated with him-- that he's 91 00:04:41,540 --> 00:04:45,540 registered 6.042 and 6.012. 92 00:04:45,540 --> 00:04:47,770 So at this point, we've applied R 93 00:04:47,770 --> 00:04:51,430 to one domain element-- one student Jason. 94 00:04:51,430 --> 00:04:53,730 But the interesting case is when you apply R 95 00:04:53,730 --> 00:04:55,810 to a bunch of students. 96 00:04:55,810 --> 00:04:58,460 So the general setup is that if x 97 00:04:58,460 --> 00:05:02,210 is a set of students-- a subset of the domain, which we've 98 00:05:02,210 --> 00:05:06,390 been showing in green-- then if I apply R to X, 99 00:05:06,390 --> 00:05:09,250 it gives me all the subjects that they're 100 00:05:09,250 --> 00:05:11,870 taking among them-- all the subjects that any one of them 101 00:05:11,870 --> 00:05:12,820 is taking. 102 00:05:12,820 --> 00:05:15,600 Let's take a look at an example. 103 00:05:15,600 --> 00:05:17,860 Well, another way to say it I guess is that R of X 104 00:05:17,860 --> 00:05:23,080 is everything in R that relates to things in X. 105 00:05:23,080 --> 00:05:27,930 So if I look at Jason and Yihui and I 106 00:05:27,930 --> 00:05:32,450 want to know what do they connect to under R-- 107 00:05:32,450 --> 00:05:35,090 these are the subjects that Jason or Yihui 108 00:05:35,090 --> 00:05:36,420 is registered for. 109 00:05:36,420 --> 00:05:40,220 The way I'd find that is by looking at the arrow diagram, 110 00:05:40,220 --> 00:05:43,970 and I'd find that Jason is taking 042 and 012. 111 00:05:43,970 --> 00:05:47,730 And Yihui is taking 012 and 004. 112 00:05:47,730 --> 00:05:51,170 So between them, they're taking three courses. 113 00:05:51,170 --> 00:06:01,340 So R of Jason, Yihui is in fact 042, 012, and 004. 114 00:06:01,340 --> 00:06:05,150 So another way to understand this idea of the image of a set 115 00:06:05,150 --> 00:06:09,290 R of X is that X is a set of points in the set 116 00:06:09,290 --> 00:06:12,770 that you're starting with called the domain. 117 00:06:12,770 --> 00:06:17,940 And R of X is going to be all of the endpoints in the other set, 118 00:06:17,940 --> 00:06:20,970 the codomain, that start at X. 119 00:06:20,970 --> 00:06:26,110 If I said that as a statement in formal logic or in set theory 120 00:06:26,110 --> 00:06:30,020 with logical notation, I would say that R of X 121 00:06:30,020 --> 00:06:34,960 is the set of j in subjects such that there 122 00:06:34,960 --> 00:06:41,260 is a d in X such that dRj. 123 00:06:41,260 --> 00:06:46,050 So what that's exactly saying that dRj 124 00:06:46,050 --> 00:06:50,170 says that d is the starting point in the domain. 125 00:06:50,170 --> 00:06:52,380 d is a student. 126 00:06:52,380 --> 00:06:55,100 j is a subject. 127 00:06:55,100 --> 00:06:58,900 dRj means there's an arrow that goes from student 128 00:06:58,900 --> 00:07:01,120 d to subject j. 129 00:07:01,120 --> 00:07:06,600 And we're collecting the set of those j's that started some d. 130 00:07:06,600 --> 00:07:10,930 So an arrow from X goes to j is what 131 00:07:10,930 --> 00:07:18,757 exists at d an X. dRj means-- written in logic notation-- 132 00:07:18,757 --> 00:07:20,840 it's really talking about the endpoints of arrows, 133 00:07:20,840 --> 00:07:22,580 and that's a nice way to think about it. 134 00:07:22,580 --> 00:07:24,560 But you ought to be able also to retreat 135 00:07:24,560 --> 00:07:28,010 to give a nice, crisp set theoretic definition 136 00:07:28,010 --> 00:07:31,870 without reference to pictures if need be. 137 00:07:31,870 --> 00:07:36,550 So that's an official definition of the image under R. 138 00:07:36,550 --> 00:07:43,190 Let's turn now to an operation on relations which 139 00:07:43,190 --> 00:07:45,350 converts one relation into another relation 140 00:07:45,350 --> 00:07:48,510 called the inverse of R. And the inverse of R 141 00:07:48,510 --> 00:07:50,780 is what you get by turning the arrows around. 142 00:07:50,780 --> 00:07:53,270 So let's look at the relation R, which 143 00:07:53,270 --> 00:07:56,320 is the registered for relation going from d students 144 00:07:56,320 --> 00:07:58,320 to j subjects. 145 00:07:58,320 --> 00:08:01,540 And then if I look at R inverse, R inverse 146 00:08:01,540 --> 00:08:04,550 I could think of as the registers relation-- 6.042 147 00:08:04,550 --> 00:08:09,460 registers Jason, and 6.012 registers Jason and Yihui. 148 00:08:09,460 --> 00:08:13,060 It's a funny usage of the word, but I needed something short 149 00:08:13,060 --> 00:08:14,670 that would fit on the slide. 150 00:08:14,670 --> 00:08:18,600 So registers is basically turning the arrows backwards of 151 00:08:18,600 --> 00:08:20,820 is registered for. 152 00:08:20,820 --> 00:08:24,780 And now I can apply the definition of image 153 00:08:24,780 --> 00:08:27,010 to R inverse in a useful way. 154 00:08:27,010 --> 00:08:30,120 But just to be crisp about what we're doing here 155 00:08:30,120 --> 00:08:32,590 is formally our inverse is gotten 156 00:08:32,590 --> 00:08:35,260 by flipping the role of the domain and the codomain. 157 00:08:35,260 --> 00:08:42,960 So we have that dRj if and only if jR inverse d. 158 00:08:42,960 --> 00:08:46,010 So let's look at R inverse of 6.012. 159 00:08:46,010 --> 00:08:48,610 What that's going to mean is all the students 160 00:08:48,610 --> 00:08:51,040 that are taking 6.012. 161 00:08:51,040 --> 00:08:55,060 So we start off at 6.012, and we go back to all the students 162 00:08:55,060 --> 00:08:56,830 that are registered for it. 163 00:08:56,830 --> 00:08:59,300 It's Jason and Yihui again. 164 00:08:59,300 --> 00:09:03,480 And so our inverse of 6.012 is Jason and Yihui. 165 00:09:03,480 --> 00:09:06,870 Our inverse of 6.012 and 6.003? 166 00:09:06,870 --> 00:09:07,880 Well, it's same deal. 167 00:09:07,880 --> 00:09:12,650 Let's look at 6.003 and 6.012 and look at all the students 168 00:09:12,650 --> 00:09:14,600 that are registered for either one of them. 169 00:09:14,600 --> 00:09:19,270 Now its Jason, Joan, and Yihui shown by those red arrows-- 170 00:09:19,270 --> 00:09:23,430 all the arrows coming out of those two courses, 003 and 012. 171 00:09:23,430 --> 00:09:28,570 And so our inverse of 003 and 012 is that set of three 172 00:09:28,570 --> 00:09:33,430 students-- Jason, Joan, and Yihui. 173 00:09:33,430 --> 00:09:35,850 And in general, when you start off 174 00:09:35,850 --> 00:09:39,310 with a bunch of subjects-- a bunch of elements-- 175 00:09:39,310 --> 00:09:42,560 of the codomain and you apply R inverse to it, 176 00:09:42,560 --> 00:09:49,320 it's called the inverse image of the Y under R. 177 00:09:49,320 --> 00:09:52,290 Well, let's look at the set J of all the subjects 178 00:09:52,290 --> 00:09:55,160 and think about what is R inverse of J. What 179 00:09:55,160 --> 00:09:55,900 does it mean? 180 00:09:55,900 --> 00:09:58,730 Well, R inverse of J is all the students 181 00:09:58,730 --> 00:10:00,330 that are registered for some subject 182 00:10:00,330 --> 00:10:03,850 at all, which is a good thing to have. 183 00:10:03,850 --> 00:10:09,070 So now, I can start using these sets to make assertions 184 00:10:09,070 --> 00:10:12,160 about my database that can be useful to know. 185 00:10:12,160 --> 00:10:15,360 So for example, if I want to say that every student is 186 00:10:15,360 --> 00:10:18,980 registered for some subject-- which, of course, 187 00:10:18,980 --> 00:10:22,670 they are-- what I would say is that D, 188 00:10:22,670 --> 00:10:28,240 the set of all students, is a subset of R inverse of J. 189 00:10:28,240 --> 00:10:34,090 So this concise set theoretic containment statement-- 190 00:10:34,090 --> 00:10:36,970 d is a subset of R inverse of J-- 191 00:10:36,970 --> 00:10:39,910 is a slick way of writing the precise statement that 192 00:10:39,910 --> 00:10:47,125 says that all the students are registered for some subject. 193 00:10:47,125 --> 00:10:48,750 Now, happens not to be true by the way. 194 00:10:48,750 --> 00:10:50,930 Because if you look back at that example, 195 00:10:50,930 --> 00:10:53,584 Adam was not registered for a subject. 196 00:10:53,584 --> 00:10:55,250 So we're not claiming that this is true, 197 00:10:55,250 --> 00:10:57,530 but simply that there's a nice way 198 00:10:57,530 --> 00:11:03,070 to express it using images and containment. 199 00:11:03,070 --> 00:11:04,730 Let's look at a different relation 200 00:11:04,730 --> 00:11:07,490 that we could call the advises relation. 201 00:11:07,490 --> 00:11:09,620 So the advises relation's going to have codomain 202 00:11:09,620 --> 00:11:14,700 the same set of students d, but it's going to have as a domain 203 00:11:14,700 --> 00:11:15,790 the set of professors. 204 00:11:15,790 --> 00:11:18,760 And I've written down the initials of five 205 00:11:18,760 --> 00:11:21,590 prominent professors minus at the top-- 206 00:11:21,590 --> 00:11:23,900 and you may recognize some of the others. 207 00:11:23,900 --> 00:11:26,540 But it doesn't really matter if you don't. 208 00:11:26,540 --> 00:11:31,080 And the advises relation V is going 209 00:11:31,080 --> 00:11:32,920 to be indicated by those arrows. 210 00:11:32,920 --> 00:11:35,290 So in particular, it shows that ARM 211 00:11:35,290 --> 00:11:38,430 is the adviser of Jason, Joan, Yihui, and Adam, 212 00:11:38,430 --> 00:11:40,440 which he happens to be. 213 00:11:40,440 --> 00:11:44,210 FTL is an adviser of Joan and Yihui. 214 00:11:44,210 --> 00:11:47,590 So Joan has two advisers because she's a double major. 215 00:11:47,590 --> 00:11:50,640 Yihui does as well. 216 00:11:50,640 --> 00:11:53,755 And Adam does as well now that I look at this example. 217 00:11:56,810 --> 00:12:03,750 So if I look at in particular now the advisees of FTL or TLP, 218 00:12:03,750 --> 00:12:09,060 I'm looking at V of the set consisting of FTL and TLP. 219 00:12:09,060 --> 00:12:11,390 And it's going to be Joan, Yihui, and Adam. 220 00:12:11,390 --> 00:12:15,140 So taking the image of FTL and TLP-- 221 00:12:15,140 --> 00:12:19,890 that's the set of advisees of either of those two professors, 222 00:12:19,890 --> 00:12:21,470 I get this set of three students-- 223 00:12:21,470 --> 00:12:24,250 Joan, Yihui, and Adam. 224 00:12:24,250 --> 00:12:27,910 Well, that's a set of students, and the registered relation 225 00:12:27,910 --> 00:12:29,190 applies to a set of students. 226 00:12:29,190 --> 00:12:30,550 So let's do that. 227 00:12:30,550 --> 00:12:34,980 If I now apply R to Joan and Yihui 228 00:12:34,980 --> 00:12:38,370 and Adam, what I'm getting is the subjects 229 00:12:38,370 --> 00:12:41,070 that they're registered for. 230 00:12:41,070 --> 00:12:44,600 So this is called composing R and V. I've applied V and them 231 00:12:44,600 --> 00:12:46,940 I'm applying R to the result. 232 00:12:46,940 --> 00:12:51,190 In this case, R of V of FTL and TLP 233 00:12:51,190 --> 00:12:53,790 is the same as R of Joan, Yihui, and Adam. 234 00:12:53,790 --> 00:12:58,676 It's the courses that any of them are taking, and it's 003, 235 00:12:58,676 --> 00:13:00,480 012, and 004. 236 00:13:05,510 --> 00:13:10,050 So the way to understand this R of V in general 237 00:13:10,050 --> 00:13:14,700 is you start off with any set X of professors in the domain. 238 00:13:14,700 --> 00:13:19,920 You take V of W-- are the advisees that they have have-- 239 00:13:19,920 --> 00:13:21,800 and then you take R of the advisees, 240 00:13:21,800 --> 00:13:25,060 and you get the subjects that the advisees are taking. 241 00:13:25,060 --> 00:13:31,110 So R of V of X is the subjects that advisees of X are taking, 242 00:13:31,110 --> 00:13:33,590 are registered for. 243 00:13:33,590 --> 00:13:35,780 Well, we can abstract that out and call 244 00:13:35,780 --> 00:13:38,840 this the composition of R and V. It's defined the same way 245 00:13:38,840 --> 00:13:40,610 that functional composition is. 246 00:13:40,610 --> 00:13:45,690 So R of V is the relation and the images of that relation. 247 00:13:45,690 --> 00:13:48,220 The images of a set of professors under R of V 248 00:13:48,220 --> 00:13:55,550 is defined to be apply V to X and then apply R to V of X. 249 00:13:55,550 --> 00:14:00,160 And it's again, called the composition of R and V. 250 00:14:00,160 --> 00:14:05,460 What it means now is that two things are related by R of V. 251 00:14:05,460 --> 00:14:08,790 It relates professors and subjects. 252 00:14:08,790 --> 00:14:10,910 And it says that a professor in a subject 253 00:14:10,910 --> 00:14:15,070 are related if the professor has an advisee-- some advisee-- 254 00:14:15,070 --> 00:14:17,700 in that subject. 255 00:14:17,700 --> 00:14:20,420 p for a professor. 256 00:14:20,420 --> 00:14:23,610 Composition of R with V. j for a subject 257 00:14:23,610 --> 00:14:27,770 holds if and only if professor p has an advisee 258 00:14:27,770 --> 00:14:30,650 registered in subject j. 259 00:14:30,650 --> 00:14:32,650 Let's see how you figure that kind of thing out. 260 00:14:32,650 --> 00:14:36,010 So I'm going to draw the V relation which 261 00:14:36,010 --> 00:14:39,380 goes from p professors to D students 262 00:14:39,380 --> 00:14:42,220 and then the R relation that goes from D students 263 00:14:42,220 --> 00:14:44,350 to J subjects. 264 00:14:44,350 --> 00:14:47,410 And by showing them in this way, I 265 00:14:47,410 --> 00:14:50,930 can understand the composition of R and V 266 00:14:50,930 --> 00:14:53,210 as following two arrows. 267 00:14:53,210 --> 00:14:58,430 You start off, say, at ARM, and you follow a V arrow from ARM 268 00:14:58,430 --> 00:15:01,140 to his advisee, Yihui. 269 00:15:01,140 --> 00:15:06,050 Then you follow another arrow from Yihui to 6.012, 270 00:15:06,050 --> 00:15:11,900 and you discover, hey, ARM has an advisee in-- 271 00:15:11,900 --> 00:15:15,910 So now we can say that professor ARM is in the relation 272 00:15:15,910 --> 00:15:21,890 R composed with V with 6.012 because of this path 273 00:15:21,890 --> 00:15:27,490 ARM has Yihui as an advisee, and Yihui is registered for 6.012. 274 00:15:27,490 --> 00:15:30,170 And this relation R o V, we figured out, 275 00:15:30,170 --> 00:15:31,910 is the relation that the professor 276 00:15:31,910 --> 00:15:34,750 has an advisee in the subject. 277 00:15:34,750 --> 00:15:36,740 So in general, what we can say is 278 00:15:36,740 --> 00:15:39,820 that a professor p is in the R o V relation 279 00:15:39,820 --> 00:15:42,290 to j if and only if-- and here we're 280 00:15:42,290 --> 00:15:45,540 going to state it in formal logical notation, which 281 00:15:45,540 --> 00:15:47,950 really applies in general, not just 282 00:15:47,950 --> 00:15:50,130 to this particular example. 283 00:15:50,130 --> 00:15:52,720 So the definition of R composed with V 284 00:15:52,720 --> 00:15:56,270 is the p R composed with Vj means 285 00:15:56,270 --> 00:16:00,610 there's a D that connects p and j through V and D, 286 00:16:00,610 --> 00:16:06,060 in particular that there's a D such that pVd, 287 00:16:06,060 --> 00:16:09,172 which means there's a V arrow from p to to d. 288 00:16:09,172 --> 00:16:13,630 And dRJ-- there's an R arrow from d to j. 289 00:16:13,630 --> 00:16:16,308 For some, d. 290 00:16:16,308 --> 00:16:18,560 By the way, there's a technicality here 291 00:16:18,560 --> 00:16:25,960 that when you write the formula pVd and dRj, following 292 00:16:25,960 --> 00:16:28,230 the diagram where you start with V on the left 293 00:16:28,230 --> 00:16:30,600 and follow a V arrow and then and R arrow, 294 00:16:30,600 --> 00:16:33,080 it's natural to think of them as written 295 00:16:33,080 --> 00:16:36,220 in left to right order of which you apply first V R. 296 00:16:36,220 --> 00:16:38,830 But of course, that's not the way composition works. 297 00:16:38,830 --> 00:16:42,940 When you apply, one function-- R to V to something, 298 00:16:42,940 --> 00:16:44,640 you're applying V first. 299 00:16:44,640 --> 00:16:46,210 And you write it on the right. 300 00:16:46,210 --> 00:16:50,840 So R o V is written like function composition 301 00:16:50,840 --> 00:16:55,530 where V applies first, but the logical statement, 302 00:16:55,530 --> 00:16:57,260 the natural way to write it, is to follow 303 00:16:57,260 --> 00:16:58,970 the way the picture works. 304 00:16:58,970 --> 00:17:01,400 And D, Vs, and Rs get reversed. 305 00:17:01,400 --> 00:17:05,088 So watch out for that confusion. 306 00:17:05,088 --> 00:17:08,119 Well, I want to introduce one more relation to flesh 307 00:17:08,119 --> 00:17:12,290 out this example, and that'll be the teaches relation. 308 00:17:12,290 --> 00:17:14,300 So the teaches relation is going to have-- 309 00:17:14,300 --> 00:17:19,030 as domain professors, again-- and it's codomain, subjects. 310 00:17:19,030 --> 00:17:21,849 And it's simply going to tell us who's teaching what. 311 00:17:21,849 --> 00:17:27,060 So here we're going to see that ARM is teaching 6.042, 312 00:17:27,060 --> 00:17:28,210 as you well know. 313 00:17:28,210 --> 00:17:32,330 And FTL is teaching 6.042, two which he does frequently 314 00:17:32,330 --> 00:17:34,890 but not this term. 315 00:17:34,890 --> 00:17:39,530 And now I can again use my relational operators 316 00:17:39,530 --> 00:17:43,650 to start making assertions about these people 317 00:17:43,650 --> 00:17:47,680 and relations involving teaching and advisees. 318 00:17:47,680 --> 00:17:50,390 And a useful way to do that is by applying set operations 319 00:17:50,390 --> 00:17:54,690 to the relations because I can think of the relations 320 00:17:54,690 --> 00:17:56,700 as being that set of arrows. 321 00:17:56,700 --> 00:18:00,290 So suppose I wanted to make some statement that a professor 322 00:18:00,290 --> 00:18:05,660 should not teach their own advisee because it's 323 00:18:05,660 --> 00:18:09,992 too much power for one person to have over a student. 324 00:18:09,992 --> 00:18:11,200 This is not true, by the way. 325 00:18:11,200 --> 00:18:13,830 It's common for professors to teach advisees, 326 00:18:13,830 --> 00:18:15,740 but there are other kinds of rules 327 00:18:15,740 --> 00:18:21,010 about dual relationships between supervisory relationships 328 00:18:21,010 --> 00:18:22,135 and personal relationships. 329 00:18:22,830 --> 00:18:25,160 But anyway, let's say if we can say 330 00:18:25,160 --> 00:18:29,980 that profs should not teach anyone one that they're 331 00:18:29,980 --> 00:18:31,100 advising. 332 00:18:31,100 --> 00:18:35,370 Well, if we were saying that in logical notation, what we would 333 00:18:35,370 --> 00:18:38,700 say is that for every professor and subject, 334 00:18:38,700 --> 00:18:43,310 it's not the case that the professor has 335 00:18:43,310 --> 00:18:46,070 an advisee in subject j and the professor 336 00:18:46,070 --> 00:18:48,124 is teaching subject j. 337 00:18:48,124 --> 00:18:49,790 So that's how you would say it in logic, 338 00:18:49,790 --> 00:18:51,790 but there's a very slick way to say it 339 00:18:51,790 --> 00:18:54,620 without all the formulas and the quantifiers. 340 00:18:54,620 --> 00:18:59,880 I could just say that T, the relationship of his teaching, 341 00:18:59,880 --> 00:19:02,980 intersected with the relationship 342 00:19:02,980 --> 00:19:07,150 of has an advisee in the subject is empty. 343 00:19:07,150 --> 00:19:14,210 There is no pair of professor and subject that is in both T 344 00:19:14,210 --> 00:19:17,150 and in R of V. 345 00:19:17,150 --> 00:19:20,740 And this bottom expression here gives you 346 00:19:20,740 --> 00:19:22,700 a sense of the concise way that you 347 00:19:22,700 --> 00:19:26,350 can express queries and assertions about the database 348 00:19:26,350 --> 00:19:30,760 using a combination of relational operators 349 00:19:30,760 --> 00:19:32,870 and set operators. 350 00:19:32,870 --> 00:19:34,860 Another way to say it by the way-- there's 351 00:19:34,860 --> 00:19:37,490 a general set theoretic fact-- is the way 352 00:19:37,490 --> 00:19:41,870 to say that T and R of V intersected is empty 353 00:19:41,870 --> 00:19:45,630 is to say that the set T and the set R of V, whatever they are, 354 00:19:45,630 --> 00:19:48,460 have no points in common. 355 00:19:48,460 --> 00:19:50,780 An equivalent way to say that is that one set 356 00:19:50,780 --> 00:19:53,490 is contained in the complement of the other set. 357 00:19:53,490 --> 00:19:57,060 So I could equally well have said this as R composed with V 358 00:19:57,060 --> 00:20:02,310 is a subset of not T. 359 00:20:02,310 --> 00:20:04,330 Well, let's step back now and summarize 360 00:20:04,330 --> 00:20:07,370 what we've done by example and say a little bit 361 00:20:07,370 --> 00:20:09,170 about how it works in general. 362 00:20:09,170 --> 00:20:12,020 So as I said, a binary relation-- and we'll 363 00:20:12,020 --> 00:20:14,470 start to be slightly more formal now-- a binary relation 364 00:20:14,470 --> 00:20:19,250 R from a set A to a set B associates elements of A 365 00:20:19,250 --> 00:20:21,330 with elements of B. 366 00:20:21,330 --> 00:20:24,570 And there's a picture of a general set 367 00:20:24,570 --> 00:20:27,880 A called the domain and a general set B 368 00:20:27,880 --> 00:20:29,590 called the codomain. 369 00:20:29,590 --> 00:20:33,090 And R is given by those arrows. 370 00:20:33,090 --> 00:20:36,150 Well, what exactly are arrows? 371 00:20:36,150 --> 00:20:38,840 Well, if you're going to formalize arrows, 372 00:20:38,840 --> 00:20:41,610 the set of them is what's called the graph of R. 373 00:20:41,610 --> 00:20:45,710 So technically, a relation really has three parts. 374 00:20:45,710 --> 00:20:48,860 It's not to be identified with just its arrows. 375 00:20:48,860 --> 00:20:51,620 A relation has a domain and codomain 376 00:20:51,620 --> 00:20:54,194 and some bunch of arrows going from the domain 377 00:20:54,194 --> 00:20:54,860 to the codomain. 378 00:20:57,940 --> 00:21:01,400 The arrows can be formalized by saying all 379 00:21:01,400 --> 00:21:04,430 that matters about an arrow is where it begins where it ends 380 00:21:04,430 --> 00:21:07,430 because it's just designed to reflect 381 00:21:07,430 --> 00:21:10,520 an association between an element of the domain 382 00:21:10,520 --> 00:21:12,370 and an element of the codomain. 383 00:21:12,370 --> 00:21:15,840 So technically, the arrows are just ordered pairs. 384 00:21:15,840 --> 00:21:18,170 And in this case, there are three arrows-- one from A 385 00:21:18,170 --> 00:21:19,230 to b 2. 386 00:21:19,230 --> 00:21:23,770 And so you see at the bottom of the slide an ordered pair a 1, 387 00:21:23,770 --> 00:21:25,290 b 2. 388 00:21:25,290 --> 00:21:27,700 Another arrow goes for a 1 to b 4. 389 00:21:27,700 --> 00:21:29,445 So you see the ordered pair a 1, b 4. 390 00:21:29,445 --> 00:21:32,680 And the final arrow is a 3, b 4. 391 00:21:32,680 --> 00:21:34,300 And you see that pair. 392 00:21:34,300 --> 00:21:36,420 So all the language about arrows is really 393 00:21:36,420 --> 00:21:39,140 talking about ordered pairs. 394 00:21:39,140 --> 00:21:43,220 It's just that the geometric image 395 00:21:43,220 --> 00:21:45,750 of these diagrams and their arrows 396 00:21:45,750 --> 00:21:50,170 makes a lot of properties much clearer. 397 00:21:50,170 --> 00:21:55,010 So the range of R is an important concept 398 00:21:55,010 --> 00:21:57,620 that comes up regularly and tends to be 399 00:21:57,620 --> 00:21:59,330 a little confusing for people. 400 00:21:59,330 --> 00:22:01,040 The range of R is simply the elements 401 00:22:01,040 --> 00:22:04,630 with arrows coming in from R. It's 402 00:22:04,630 --> 00:22:09,440 all of the elements that are hit by an arrow that 403 00:22:09,440 --> 00:22:11,980 starts in the domain. 404 00:22:11,980 --> 00:22:17,400 So it's really R of the domain is the range of R. 405 00:22:17,400 --> 00:22:21,040 Now, notice that this is typically not 406 00:22:21,040 --> 00:22:23,790 equal to the whole codomain. 407 00:22:23,790 --> 00:22:25,310 Let's look at this example. 408 00:22:25,310 --> 00:22:28,430 Here, the range of R-- the points 409 00:22:28,430 --> 00:22:32,740 that are hit by elements of A under R, namely just b 2 410 00:22:32,740 --> 00:22:34,460 and b 4. 411 00:22:34,460 --> 00:22:38,506 The codomain has elements b 1 and b 3 that are missing 412 00:22:38,506 --> 00:22:39,755 and that are not in the range. 413 00:22:42,310 --> 00:22:45,050 Well, as I said, functions are a special case of relations. 414 00:22:45,050 --> 00:22:47,130 So let's just look at that. 415 00:22:47,130 --> 00:22:51,240 A function, F, from a set A to a set B 416 00:22:51,240 --> 00:22:54,500 is a relation which associates with each element 417 00:22:54,500 --> 00:22:57,255 in the domain-- each element little a and the domain capital 418 00:22:57,255 --> 00:23:04,350 A-- with at most one element of the codomain B. 419 00:23:04,350 --> 00:23:07,730 So this one element, if it exists, is called F of a. 420 00:23:07,730 --> 00:23:13,190 It's the image of the element a under the relation F, 421 00:23:13,190 --> 00:23:17,120 but what's special about it is that F of a contains at most 422 00:23:17,120 --> 00:23:18,390 one element. 423 00:23:18,390 --> 00:23:21,110 So let's just look at an example again. 424 00:23:21,110 --> 00:23:24,080 A way to say that a relation is a function 425 00:23:24,080 --> 00:23:29,320 is to look at all of the points on the left in the domain 426 00:23:29,320 --> 00:23:33,530 and make sure that none of them have more than one arrow coming 427 00:23:33,530 --> 00:23:34,180 out. 428 00:23:34,180 --> 00:23:37,810 Well, in this picture, there are a couple of violations of that. 429 00:23:37,810 --> 00:23:40,060 There are a couple points on the left in A 430 00:23:40,060 --> 00:23:42,220 that have more than one arrow coming out. 431 00:23:42,220 --> 00:23:45,070 [? There's ?] our two bad edges. 432 00:23:45,070 --> 00:23:48,960 But if I erase those, now I'm left with a function. 433 00:23:48,960 --> 00:23:52,160 And sure enough, there's at most one arrow coming out 434 00:23:52,160 --> 00:23:55,320 of each of the points on the left in A. Some of the points 435 00:23:55,320 --> 00:23:56,510 have no arrows coming out. 436 00:23:56,510 --> 00:23:57,870 That's fine. 437 00:23:57,870 --> 00:24:02,200 And so for those green points with an arrow out, 438 00:24:02,200 --> 00:24:07,460 there's a unique F of the green point equal to a magenta 439 00:24:07,460 --> 00:24:11,980 point in B that's uniquely determined by the functional 440 00:24:11,980 --> 00:24:16,010 relation F, which may not be defined for all 441 00:24:16,010 --> 00:24:18,791 of the green points if they don't have any arrow coming out 442 00:24:18,791 --> 00:24:19,290 of them. 443 00:24:19,290 --> 00:24:23,605 So function means less than or equal to 1 arrow coming out. 444 00:24:26,210 --> 00:24:29,020 So if we set this formally without talking 445 00:24:29,020 --> 00:24:31,620 about the arrows, one way is simply 446 00:24:31,620 --> 00:24:36,980 to say that a relation is a function 447 00:24:36,980 --> 00:24:40,460 if the size of F of little a is less than or equal to 1 for all 448 00:24:40,460 --> 00:24:44,470 of the domain elements A. 449 00:24:44,470 --> 00:24:48,150 And a more elementary way to say it 450 00:24:48,150 --> 00:24:51,130 using just the language of relations and equality 451 00:24:51,130 --> 00:24:53,940 and Boolean connectives is to say 452 00:24:53,940 --> 00:24:57,500 that if a is connected to two things 453 00:24:57,500 --> 00:25:03,110 by F-- if aFb AND aFb prime-- then in fact 454 00:25:03,110 --> 00:25:06,690 b is equal to b prime. 455 00:25:06,690 --> 00:25:10,680 And that wraps up functions.