 Welcome back to our lecture series, Math 3120, Transition to Advanced Mathematics for Students at Southern Utah University. As usual, I'll be a professor today, Dr. Andrew Missildine. In this first video for lecture 28, we can introduce the notion of modular arithmetic, which is one of the most important relations that we can place on the set of integers. Now, in previous lectures in this series, we've already introduced the notion of relations. That is how we can compare things together using Cartesian products of things. Particularly, we introduced important notions of equivalence relations and partial orders. And so as we draw to the near end of our relation unit, we introduced this important relation about modular congruence onto integers. And we'll do some more about this in lecture 29 as well. And so the congruence relation on integers is dependent upon a number, which we commonly refer to as the modulus. That modulus can be any natural number, N, ranging from zero, one, two, three, all the way up to any natural number you want there. And so with that in mind, there's gonna be different relations for different moduli. And so do pay attention to that as we go work throughout these examples here. So, okay, what is the relation then? We say that two integers, and these can be positive, negative, zero, don't care, we say that two integers, R and S, are congruence to each other, modulo N. Now, we oftentimes drop off the word modulo N if we know which modulus is in play here, but the relation does depend on the modulus. I mean, that's often abbreviated as mod short there. So we say that R is congruent to S mod N, and this will be denoted in the following way here. R is congruent to S modulo N. This happens if and only if N divides their difference R minus S, which of course, what does it mean for N to divide the difference R minus S? It means there exists some integer K such that RS is equal to K times N. So that's what this relationship here means that R is congruent to S exactly when R minus S is a multiple of the modulus N there. So let's try to take a look at some examples. So we can say that 10 is congruent to one, modulo three, because the difference between 10 and one, which is nine, is divisible by three. Nine is three times three. Likewise, we can say that 15 is congruent to zero, modulo five, because when you take the difference, 15 minus zero, which is itself 15, that's divisible by five. You get three times five there. We should see a case where it's not actually congruent. 15 is not congruent to zero, modulo seven, because like we saw before, 15 minus zero is 15, and 15 is not divisible by seven. So when it comes to these modular congruences, the modulus itself does matter very much so. So 15 is congruent to zero, mod five, but 15 is not congruent to zero, mod seven. A different modulus gives you very different things there. Just a few more examples I have here on the slide. 30 is congruent to 48, mod nine, and you can see what happens here. 30 minus 48 is equal to negative 18, and that's of course the same thing as negative two times nine here. It actually doesn't matter which order you go, because if you did it the other way around, if you took 48 minus 30, in that case you actually get a positive 18, which is equal to two times nine. And so we're gonna start, we're gonna see this in a little bit, but it turns out this relation is in fact a symmetric relation. It's also going to be reflexive. It's also gonna be transitive. Oh, that kind of sounds like an equivalence relation, right? We'll see that in just a little bit before the end of this video. But one more example here, 23 is congruent to two, mod seven, because 23 minus two is equal to 21, and 21 is divisible by seven, okay? So this gives us this notion of the congruence modulo sum natural number here. And just so you're aware, when we talk about the natural numbers here, this includes zero as an option. You can ask, like, are integers congruent modulo zero? A lot of authors, when they talk about modular integers, they don't allow for zero. They only allow for positive integers in that case. But there's actually nothing wrong with doing zero, mod zero here. It's kind of interesting because in that situation, if you have A is congruent to B mod zero, what that means is zero divides A minus B, all right? And so we need some integer K such that K times zero, which has to be zero is equal to A minus B here. You get A minus B. And so it's kind of silly here, but if two integers are congruent mod zero, they actually have to be equal as integers. So modulo zero doesn't give you a new relation. It's just the usual equality relation on integers. But as you take other moduli, you can get a different relation. And so it's not wrong to include zero. A lot of people omit it because it's not offered anything new. But I do want to point out that modulo zero does make sense. Now, people often include the positive integers there. And I'd like to mention that if you ask our things congruent modulo one, it's honestly just as silly to talk about modulo one as it is modulo zero, because if A is congruent to B modulo one, that means that one divides A minus B. But hey, one divides everything, right? One divides every integer. So we need to have A minus B, which is equal to K times one, but the K is just A minus B itself times one. So that's sort of the other extreme. When you're mod zero, you just get the usual equality here. But if you're mod one, you get that everything is congruent to each other. So we don't usually work mod zero, mod one, because there's kind of these silly trivial cases. But when you start talking mod two, mod three, mod four, this gives you a very interesting relation on the integers. And I should also mention that if you're trying to tech this thing up, this symbol right here is backslash equiv short for equivalent. And then also this symbol right here, you're actually gonna do, there is a backslash mod command, but it doesn't get the spacing right all the time. You wanna use backslash pmod, for which it then takes in your modulus as a command. That'll put the spacing and the parentheses just right. They'll make it look adorable in your latex documents there. So with a relation now in hand, it makes sense to consider properties about that relation. I hinted to the fact that it's an equivalence relation. We will get to that in just a moment. I actually wanna look at some algebraic properties that this congruence modulo n satisfies, which is actually one of the reasons why we care about it so much. So imagine we have three integers abc, and we have a modulus n, then it does hold that if a is congruent to b modulo n, then a plus c will be congruent to b plus c modulo n. So the idea here is that if you have two numbers that are congruent to each other, if you add the same value to both sides, you still be congruent to each other. So in some aspects, like this is what equality does, right? If a equals b is integers, then a plus c equals b plus c. So this congruence modulo n will satisfy this variance under addition property, okay? And to see that, let's just go through the proof. Let's look at the definitions of these things. Suppose that a is congruent to b modulo n. Well, that means there exists, so of course this means that n divides a minus b. So there exists some integer k such that ab is equal to kn. I want you to now to consider the difference of a plus c minus b plus c, because what we wanna do is we wanna show with this one over here, if a plus b is congruent, excuse me, if a plus c is congruent to b plus c, that means that a plus c minus b plus c is supposed to be divisible by n. That's the definition there. So we're gonna consider the difference there, a plus c minus b plus c, but notice the c's cancel out, you just get back a minus b again, which of course as we observed earlier was k times n. So n does divide the difference of a plus c and b plus c. So this tells us that a plus c is congruent to b plus c. So if you have two integers that are congruent, then adding the same number to both sides will still make it congruent, all right? A similar property here. If you have three integers, a, b, c, and you're working modulo n, if a is congruent to b modulo n, then a minus c is congruent to b minus c mod n. Now, this is one of those situations where I'm gonna leave the proof up to the reader, or proof up to the viewer in this regard here. This is something that's commonly done in mathematical courses and textbooks, and that's because the proof here is so similar to the previous one that me providing a second one is not gonna do you any good, but you writing it actually will be very educational for you. And honestly, it's just take the previous proof that's now off the screen and change the appropriate parts. You're gonna get subtraction as well. So integer congruence, it's invariant under addition. It's also invariant under subtraction. You perhaps can see where we're going here. What about integer congruence? Is it invariant under multiplication? If I take three integers, a, b, c, and a modulus n, if a, b is congruent to, sorry, if a is congruent to b mod n, then a, c is congruent to b, c mod n, all right? So I claim that integer congruence is invariant under multiplication, all right? We're doing the exact same type of proof that we did before. Again, you just unravel the definition of this relation. So suppose that a is congruent to b modulo n, that means there's some integer k such that the difference a minus b is equal to k times n. So now I wanna show this congruence is gonna hold. So I have to consider the difference a, c minus b, b, c here. I need to argue that n divides this difference. So I'm gonna consider the difference there, a, c minus b, c. But this is just an algebraic statement of integers. a, c minus b, c, there's a common divisor of c that you can factor out, c times a, b. And by assumption here, a minus b is equal to k, n. So we get that a, c minus b, c is equal to c times k, n. Therefore, n divides a, c minus b, c. And that then gives us that a, c is congruent to b, c. So all right, so what we have so far is that integer congruence is invariant under addition, subtraction, and multiplication. What about division? Division gets a little bit more problematic because, well, if you divide two integers, you don't necessarily get an integer anymore. Like one divided by two is not an integer. And so division is a little bit more problematic. We will consider that in our next video there in our lecture series. So going on, I do want to mention another property here. If we have two integers a and b, and we have a modulus n, if a is congruent to b mod n, it's also true that the squares are congruent to each other as well. a squared is congruent to b squared mod n. And the proof is basically the same. Suppose a is congruent to b mod n. Then there exists some integer k such that a, b is equal to kn. If I want to show that a squared is congruent to b squared, I need to consider their difference, a squared minus b squared. I need to argue that n divides a squared minus b squared. So we take that difference right there, a squared minus b squared. Now, that isn't difference of squares. I can factor that thing. I get a plus b times a minus b. And while I don't know anything about a plus b, I do know that a minus b is divisible by n. So we can make that substitution here. a minus b is equal to kn. Therefore, a squared minus b squared is equal to a plus b, which is something, times kn. We then can see that n divides the difference of squares. n divides a squared minus b squared. And this then gives us that a squared is congruent to b squared mod n. And I want to mention that this actually continues on for other powers as well. While the factorization is a little bit more complicated, you can do a similar argument that a cubed is congruent to b cubed. a to the fourth is congruent to b to the fourth. a to the 5 is congruent to b to the 5, et cetera, et cetera. So in general, we can actually replace this with the following a to the n. We already have an n. a to the m is congruent to b to the m modulo n. That all exponents are going to be congruent to each other if a to the b is, if a is congruent to b here as well. So we've looked at all these algebraic properties of modular arithmetic. And this is actually why we refer to it as modular arithmetic. We can actually get some very nice arithmetic properties. Again, we'll delve into that a little bit more into the next video here. So before we end this video, there is one more thing I do need to talk about. So let's play with this definition a little bit longer here. So note, if a is congruent to b mod n, this implies that n divides the difference a minus b. Now I want us to do some division here. We talked about division a little bit earlier. While we're not gonna do modular division in this video, think about the division algorithm on integers. So if you take the number a and you divide a by n, there exists some quotient q and some remainder r such that a is equal to qr plus, excuse me, a equals qn plus r where r sits in between zero and a, excuse me, n. Then we can do the same thing here. If I take b and divide it by n, there's gonna exist some quotient and remainder called them p and s such that b is equal to pn plus s where again, we can assume that s is congruent equal to zero, but less than n. Like so, again, this is a consequence of the division algorithm, all right? So if you take this divisibility statement, n divides a minus b, clearly you can also observe that n divides q minus p times n. I mean, clearly you can see the factorizations there. Why is that relevant? Well, then I claim that n divides the difference of the remainders, r minus s like so. And so notice that r, based upon the original equation if you solve for r right here, r is the same thing as a minus qn. And similar, if you solve this equation for s, you're gonna get that s equals b minus pn. So r minus s is equal to a minus qn minus b minus pn. Simplifying those things, you're gonna get an a minus b minus a q minus p times n here. And so, hey, that's exactly what we had before. a divides, excuse me, n divides a minus b by assumption. n divides q minus p times n, obviously. And therefore it has to be the case that n divides r minus s because r minus s is a difference of things divisible by n. But this is where this comes into play now. Remember, r is less than n, so is s. So when we take the difference of r minus s, since r is less than n, this difference has to still be less than n. But since s itself also is less than n, when we take this difference here, I'm not supposing r is the bigger of the two, but the point is this difference has to sit somewhere between, has to sit somewhere in between n and negative n. But n divides this. And so the only possibility, the only multiple of n that sits in between n and negative n is gonna be zero. So we can actually conclude that r minus s is equal to zero, which then tells us that r equals s. And so now summarizing what we just discovered here, if a is congruent to b mod n, it actually means that a and b have the same remainder if divided by n. And when you use that word same remainder, they have the same remainder when you divide by n. This is then to suggest why this is in fact an equivalence relation. An equivalence relation measures when two things are somehow the same. And this congruence modulo n relation is measuring what is the remainder. When things have the same remainder, they're gonna be congruent to each other. This is in fact an if and only if statement. We went in one direction. We show that if they're congruent, they'll have the same remainder, but you can actually go the other way around. If they have the same remainder, then they'll be congruent modulo n. And you can reverse the directions. I'll leave that as an exercise to the viewer here. So in particular, this congruence relation is an equivalence relation. Let's prove it officially here. Congruence modulo n is an equivalence relation on the integers for any positive integer n. And honestly, I can just say any natural number. Any natural number. It doesn't have to be just to be a positive. It could be zero as well. So let's first argue that it's reflexive. So note that if I take r minus r, that's equal to zero. And zero is gonna be equal to zero times n. So regardless of what your modulus is, we do get that r is congruent to r. So this is a reflexive relation. Symmetry, we've talked about that a little bit already, but let's prove it now. If r is congruent to s modulo n, that means that r minus s is equal to kn for some integer here. Now, if you take this equation and you times both sides by negative one, you're gonna end up with on the left-hand side, you're gonna get s minus r. On the right-hand side, you're gonna get negative k times n. This shows that n divides s minus r because negative k is still an integer. This then shows that s is congruent to r mod n. So if r is congruent to s, then s is congruent to r. We have the symmetric property. Now, the last one to be an equivalence relation is we have to do transitivity. This one's a little bit longer, but we can handle it. So for transitivity, we have to show that if r is congruent to s and s is congruent to t, we then wanna show that r is congruent to t. That's what our goal is. So, okay, so assume r is congruent to s and s is congruent to t. Now, if r is congruent to s, that means that n divides r minus s. So there's some integer k such that r minus s is equal to k. Likewise, if s is congruent to t, then that means that s minus t is divisible like n. So there exists some integer, we'll call it l, such that s minus t is equal to l times n. So then what we're gonna do is we're gonna take these two expressions and combine them together. Cause notice, if I take r minus t, this is the same thing as r minus s plus s minus t. The s is canceled out in this situation. But of course, the advantage here is r minus s is the same thing as kn, s minus t is the same thing as lk, sorry, ln. And so kn plus ln, you can factor that as k plus ln, which of course, k plus l is an integer. And so this shows us that r minus t is divisible by n and that then gives us that r is congruent to t mod n. So we do in fact have an equivalence relation for any natural number. And this proof never required anything other than we had a natural number there. So we can extend this, even though we're never gonna work mod zero or mod one, be aware this proof holds for every possibility, every possible natural number there. So because we have an equivalence relation, it makes sense that we can talk about the equivalence classes. Every equivalence relation provides a partition on the set associated to the equivalence relation. And that gives us our equivalent classes. So since this is an equivalence relation, what would the equivalence classes be when we work mod n? For this example, we're gonna do specifically n equals three. So it turns out that if you're doing integer modulo, integers modulo three, you're gonna get three equivalence classes. Just so you're aware in the situation of modular arithmetic, these are commonly referred to as the congruence classes. So the congruence classes are just the equivalence classes associated to the equivalence relation congruence modulo n. Now, if you're working mod three, you're gonna get three congruence classes. There's gonna be the class that is represented by zero. This will include zero, three, six, nine, 12, 15, negative three, negative six, negative nine, et cetera, and particularly it's gonna get all of the multiples of three. Because remember, these elements are equivalent to each other, the congruent to each other, if they have the same remainder when you divide by three. And so the multiples of three are gonna be those numbers. When you divide by three, you get a remainder of zero because they're actually multiples of three. Likewise, there is going to be a congruence class associated to the number one. This will include one, four, seven, 10, 13, negative two, negative five, et cetera. These numbers are those numbers for when you divide by three, you get a remainder of one. Another way to think about it here is that when you go from the next one to the next one, you're just adding three. One plus three is four, plus three is seven, plus three is 10, plus three is 13. This sequence forms an arithmetic progression where you're increasing three each and every time. That was also true, of course, for the multiples of three. And then the last congruence class here is gonna be the congruence class represented by two. This will include two, five, eight, 11, 14. Notice you can get from one number to the next just by adding three over and over again. If you subtract three, you go the other way around, negative one, negative four, et cetera. Again, this set forms an arithmetic progression where you're increasing throughout the sequence always by adding three there. And so these are the three congruence classes associated to the integers mod three. If you take the union of each of these things, so the union of the congruence class for zero, one, and two gives you all of the integers. These sets are in fact disjointed, forms a partition. And there's just the three of them, just the three of them. The set, these three congruence classes gives you all of them. And it's not a coincidence that there are three congruence classes, and our modulus was three as well. Okay? So again, excluding the case where your modulus is zero or one, that's where you can get a little bit weird here. I guess one's not so weird in this situation, but in general, what you see is if you take any modulus whatsoever, n, the number of congruence classes that you have is gonna equal n. So working modulo n, you get n, congruence classes. And each of these classes can be represented of the form, the congruence class of x, where x is some number that sits between zero and n. Because after all, the congruence classes are determined by the remainder of the integer we divide by n. And by the division algorithm, the remainder will sit anywhere between zero and n, not including n, but you can get zero. So you get zero, one, two, three, four, five, all the way up to n minus one. So your congruence classes look exactly like that. You get a congruence class for zero, congruence class for one, congruence class for two, all the way up to a congruence class for n minus one. All of the possible remainders when you divide by n, you get those. And so these remainders are actually like the poster child for the congruence classes. It's the ideal representative for that. We can always denote the congruence class using the remainders, because they all have that common remainder. All right? Like I said, zero is a little bit funky in that situation, because in that case you have, it's a little bit different. But for any pause, integer, this statement would then in fact hold. So what we're gonna do as we end this video is we're gonna introduce a new symbol. We're gonna denote the symbol z sub n to be the set of congruence classes. All right, so z sub n as a set will contain the congruence class zero, the congruence class one, the congruence class two, all the way up to the congruence class of n minus one. Like so. I should then note that the cardinality of this set is in fact equal to n. Again, so long as n doesn't equal zero. Zero is a little bit exceptional in this case. It doesn't, the definition of the relation makes sense when it equals zero, but this set n sub zero is a little bit weird if you have zero in there. So we'll only do that for positive integers. This is the main reason why zero gets kicked out. But we then define this set n sub zero to be the set of all congruence classes on the integers module n. And I want to mention that this is sort of an analog to how we define the rational numbers. Remember the rational numbers, we then define to be a set of congruence classes. We write p over q, where of course p and q are integers, where q doesn't equal zero. But that number, the number p over q is really just a congruence class for these ordered pairs that we had talked about previously when we introduced congruence classes or when we introduced equivalence equations, I should say. So the rational numbers by definition is a set of equivalence classes. We're gonna do the same thing with these modular integers. And we're gonna see next time, just like how q has a very nice algebraic structure that we can add to track both by divide. We can do a similar thing for z sub n, but again, we'll do that one next time.