 Welcome back, we are looking at solutions of linear congruence equations. So, this is of the type AX congruent to B modulo N and we are looking at solutions to such an equation. We saw that there is a solution precisely when the GCD of A and N call it D, it divides B. So, if the GCD does not divide B then there is no solution at all. However, if the GCD divides B then sometimes there can be a unique solution and sometimes there can be more than one solutions. So, we saw all this in our last lecture. So, let us just go through that once again. We have that the linear congruence AX congruent to B mod N has a solution if and only if D which is A, N the GCD that divides N. So, once again I would like to point it out to you that there are these two directions to proving this. The first one for if it would mean that the congruence has a solution if D divides B. So, we will assume that D divides B and we will prove that the congruence has a solution and in the other direction the congruence has a solution only if D divides B. So, that means when the D does not divide B the congruence does not have a solution or we need to prove that congruence has a solution then D should divide B. So, there are these are the two directions which we have proved already. We also then later saw that whenever you have one solution. So, now you assume that D is a divisor of B so that there is a solution and so suppose one solution is named X naught then all other solutions in the set of integers are obtained by the formula X naught plus N by D into T. So, this is the formula which gives us all the solutions. In particular if you are looking at solutions modulo N then there are exactly D solutions. So, in particular precisely D solutions in the set of residue classes modulo N. So, once this is understood we wanted to know whether there is an algorithm for solving linear congruences and there is indeed an algorithm we saw that in the last lecture. So, let us go through that once again. What we want to do is to solve the congruence AX congruent to B modulo N. So, A is given to us B is given to us and N is given to us and we want to solve this congruence AX congruent to B mod N. The very basic step is to check whether the GCD of A and N divides B. If the GCD does not divide B then there is no solution and we are done. However, if the GCD does divide B that means this D divides all of the A, N and B. And then we go to the next step which is that we cancel D from all these numbers. So, here I have A by D, here we have B by D and here we have N by D. We cancel D from all these three numbers and obtain a congruence for which the coefficient of X is small. Ultimately what we want to do is to cancel this coefficient of X, make it 1. That is what we would want to do. So, if you have an equation where the coefficient of X is 1 it would read like X congruent to B mod N and then that is the solution that we have. So, that is where we are going. We are trying to reduce the coefficient of X. That is why we have divided by D throughout. And now the third step is to seek whether we can reduce the coefficient of X further. So, there are two methods to doing it. But before we go to do that we need to prove the statement that we have made here. That when you solve this, so what we want to show is that solution to this is equivalent to having a solution to this. Are these equivalent and this proof is needed. So, we will give this proof and we will also see what. So, we will answer this also. How do we do this? There is one method which I will tell you and then there is another impromptu method which also will come. So, right now we are going to prove state and prove the first part which reads as follows. So, suppose we have that M divides each of the A, B and N and if M divides them then let us just divide them and get a smaller triple A prime, B prime and prime then this system has a solution if and only if this system has a solution. So, we want to say that the larger system where A is big has a solution if and only if the smaller system where A prime is smaller than A also has a solution. So, as I keep telling you there are two parts if and only if. If means that we assume this and prove this and only it means that you assume that part and prove this part. So, A x congruent to B mod N has a solution if A prime x congruent to B prime mod N prime has a solution. Therefore, we will assume this part first and then prove this and then we will come back in the other direction. So, here we go with the proof we assume A prime x congruent to B prime mod N prime has a solution let it be alpha. So, we have some solution in the set of integers then N prime divides A prime alpha minus B prime which is to say actually. So, I should not really call this as implies but we are just going to rewrite this that N by D divides A by D alpha minus B by D. So, this we are just rewriting this statement because N prime is N upon D, A prime is A upon D and B prime is B upon D or in fact there is no D we have assumed that there is an integer m which divides all this does not have to be equal to the GCD. So, we have this m coming here but if you have this m you can take this m common from the right hand side. So, what we get is that N by m divides 1 by m A alpha minus B and this implies that N divides A alpha minus B because I can simply write this part as N by m into some beta and then we cancel these m's which come in the denominator to obtain this result. So, these get cancelled therefore we have A alpha minus B is N into beta and therefore N divides A alpha minus B. So, we had started by assuming that our congruence A prime thus a solution to A prime x congruent to B prime mod N prime gives a solution to A x congruent to B mod N. So, this was the if part which is that assuming that there is a solution to the smaller equation with smaller coefficient of x we have proved that there is a solution to the bigger equation. Now, we want to prove the other way. So, we will start with assuming we now assume that A x congruent to B mod N has a solution say gamma this is some integer and we have equation this congruence has a solution. So, that means N divides A gamma minus B. But now we have that m divides all of the N A and B. So, we can then write N m into N by m divides m into A by m gamma minus B by m. So, what we do is that we take m common from all these terms and then that gives us that m into N prime divides m into A prime gamma minus B prime which implies that N prime divides A prime gamma minus B prime because we can write this as m into N prime into some number say data and then we simply cancel out this m on both sides to get that A prime gamma minus B prime is N prime into delta and therefore, N prime divides A prime gamma minus B prime. So, thus a solution to A x congruent to B mod N gives a solution to A prime x congruent to B prime mod N prime. So, we have proved this in both the direction we started with assuming that there is a solution to the smaller equation and obtained a solution for the bigger equation larger equation. And then we started with a solution to the larger equation and obtained a solution for this smaller equation. So, the existence of solutions for both of these congruences are equivalent the existences are equivalent. The number of solutions will change because it will depend on the number N and the D what may happen is that once you have a GCD D of A and N and suppose that it divides B and if you happen to cancel out this GCD throughout giving you a smaller equation then in the smaller equation the GCD will now become 1 and therefore, in the smaller equation you will have a unique solution whereas in the larger equation you will have D solutions. So, the number of solutions is not going to change what the number of solutions is going to change possibly what does not change is whether the solution exists in the very first place. So, this was the first stage where you just simply cancelled out the GCD from the GCD or a common divisor of all the A, B and N. Now the question is the thing that we had we asked can you reduce the coefficient of x further and this can indeed be done this is so what we now assume is that the GCD of A and N is 1 this is our assumption and now we will play only with A and B and then reduce that coefficient of x which is A. So, it goes as follows we have that the GCD of A and N is equal to 1 therefore, there is a guarantee that the solution exists. In fact, we are now going to get a unique solution because the GCD is 1 suppose that M divides A and B. So, remember that we have the congruence A x congruent to B mod N there is a number M which divides both the coefficient of x and the constant term. Then we divide by M to obtain a new A call that A prime which is A upon M and a new B which is B prime which is B by M. Then our original congruence A x congruent to B mod N has a solution if and only if A prime x congruent to B prime mod N has a solution. So, here we have reduced the coefficient of x by having divided it by M of course, as a bonus we got that this also got reduced. So, whenever you have a common these N has not changed N has remained as it is what has changed are the coefficients of x and the constant term. So, once again we have two parts if and only if so we will assume the A prime x congruent to B prime mod N has a solution and prove that A x congruent to B mod N has a solution and then we prove the only if part which is to go from the larger equation to the smaller equation. So, the proof begins by assuming that so we assume that A prime x congruent to B prime mod N has a solution call that alpha. So, what we then get is that N divides A prime alpha minus B prime, but remember that A prime was A upon M. So, we just rewrite this as A upon M alpha minus B upon M and clearly this number is going to divide A alpha minus B because this is nothing but 1 upon M A alpha minus B or you may consider this as M times A by M alpha minus B by M. So, what we do get is that N divides A alpha minus B or A x congruent to B mod N has a solution. So, we started with this smaller equation which was A prime x mod A congruent to B prime mod N has a solution and we proved that the larger equation has solution. So, thus the solution to A prime x congruent to B prime mod N gives a solution A x congruent to B mod N. We want to now go in the other direction. So, we will assume that the larger equation has a solution and we want to obtain a solution to the smaller equation you would have noticed that there is something that we have not used yet which is that A comma N equal to 1 is not yet used. This is going to be used in the second part. So, second part is where we will assume that the bigger equation has a solution and we will prove that the smaller equation also has a solution say beta in the integers. Then N divides A beta minus B but M is a common divisor of A and B. So, we can write this equation as M into A by M beta minus B by M. Now, we have come to the equation our assumptions observe that M divides A and A comma N is 1 which means that there is not a single prime which divides both A and N. The greatest common divisor of A and N is 1. So, there is no common divisor in particular there cannot be any common prime divisor and here M is a divisor of A. So, the prime factors of M are nothing but the prime factors of A. So, what we get is that the GCD of N and M is also 1. Here we have that N divides a product of M and some number but N and M will have no common factor. So, every prime which occurs here will have to go and occur in the prime factorization of this number. Note that this is a number here we have that both A by M and B by M these are natural numbers. We are not looking at rational numbers but natural numbers. So, therefore, what we must get is that N will in fact divide the right hand side A by M beta minus B by M which implies that A prime X congruent to B prime mod N has a solution. So, thus a solution to the bigger equation AX congruent to B mod N gives a solution the smaller equation which is A prime X congruent to B prime mod N keeping the modulus of the congruence constant. This completes the proof. So, remember once again that we have carried out two steps of the algorithm after having checked that the GCD divides B. Step one was to cancel out the GCD from A, B and N and getting a solution to the smaller equation is equivalent to having a solution to the original equation the bigger equation that was our assumption that was the first lemma that we proved. Then the second lemma told us that if you have anything common in A and B assume that A and N have GCD 1 and further if you have anything common in A and B then even that can be cancelled out. Thus you can reduce the coefficient of X further. In both these groups you would have noticed that the solution that we had started with in both the situation is the solution for the other system. In lemma 1 when we cancelled out M and looked at A prime X congruent to B prime mod N prime we started with a solution alpha the same alpha continued to be a solution for the original equation AX congruent to B mod N and in the reverse direction we started with a solution gamma to AX congruent to B mod N and gamma itself was again a solution for the smaller equation A prime X congruent to B prime mod N prime. In the second lemma where we cancelled out a common factor only from A and B the solution again did not change. We started with alpha which was a solution to A prime X congruent to B prime mod N the same alpha became a solution to AX congruent to B mod N and in the reverse direction as you can see here the beta which was a solution to AX congruent to B mod N continued to be a solution to A prime X congruent to B prime mod N. Now these two lemmas have enabled us to take some more steps so let us see whether we can solve one such congruence equation in the next slide. So we want to find all solutions to 12x congruent to 18 mod 22. Our algorithm says that you compute the GCD. The GCD of 12 and 22 if you want to use the division algorithm will give you the GCD to be the GCD of 12 and 10 which is further the GCD of 2 and 10 and therefore this is 2. 2 divides 18 so we have a solution in fact two solutions these will be X naught and X naught plus 11 modulo 22. 11 is 22 upon 2 so that is step 1 which is completed. So step 2 will tell us that solve 6x congruent to 9 mod 11. This is the step 2 that we want to now solve 6x congruent to 9 mod 11 where 6 is nothing but 12 upon 2 the GCD is now getting cancelled 9 is 18 upon 2 and 11 is 22 by 2. So this is an equation which we want to solve. Let us go to the next slide and try to solve this equation 6x congruent to 9 mod 11. Now we observe that both our now 6 and 9 have a GCD which is 3 and of course 6 and 11 have the GCD 1 now. So we apply the second lemma that we have proved. So step 3 says solve 2x congruent to 3 mod 11 because we have cancelled out 3 from both these coefficients this remains as it is but this is now a very simple thing 6 2x congruent to 3 mod 11 can be completed quite easily. I will simply multiply by 6 on both sides. This is going to be 12x which is simply x this is 18 which is simply 7. So this is the solution that we are looking for. So thus 7 and remember we have to add 7 plus 11 which is 22 upon 2 these solutions modulo 22. So we have obtained a solution by applying all the steps we have learned. There is one more impromptu step which we can add but we will see this step in the very next lecture. So I hope to see you again. Thank you.