 Welcome back. In our last lecture we have done a very intricate analysis of computing the number of the square roots of 1 in Z mod nz. It was first of all factoring n into several prime powers and then solving the equation x square equal to 1 modulo these prime powers that gave us linear congruences mod each of these prime powers and then we got a set of systems of simultaneous linear congruences which have unique solution modulo the product of all those moduli which is your n and that is by Chinese remainder theorem and so we can compute the exact number of solutions to x square congruent to 1 modulo n. I would suggest that you takes n equal to some number like 30 or say 48 and actually work out all those things quickly and that will tell you how that intricate analysis works in some very particular cases. Now we are going to take our attention to somewhat different type of mathematics. In number theory there is a function called the factorial function. This is one symbol that is lifted from literature which is the symbol of the exclamation mark and we use it to denote the factorial. So, a factorial is 1 into 2 into 3 into dot dot dot all the way up to a that is our factorial function it is a expanding function as a goes to infinity a factorial goes to infinity much faster than any polynomial in a. However, when you look at the z by nz or in particular the z by pz the factorial function is not going to increase because when you look at z mod nz you take powers or you take products you are allowed to take the multiples of n out. You after all have only finitely many elements in z mod nz you have exactly n elements in z by nz starting from 1 to n or if you want to start from 0 then you go up to n minus 1. So, it is interesting to ask what would happen when you take the factorial function in such a ring and this is a very interesting result that we now have this is called Wilson's theorem. So, the theorem says that when you take a prime p and you take p minus 1 factorial. So, that means you take the set z mod pz remove 0. So, you have all the non-zero elements there 1, 2, 3 up to p minus 1 if you include p that p is 0. So, we are not going to include that back. So, you have only the non-zero elements 1, 2, 3 up to p minus 1 p minus 1 factorial is the product of all these numbers and it is interesting to note that this is equal to minus 1 when you are working in the set z mod pz. Now, this very important and very basic theorem is given the name of this mathematician John Wilson. But as it happens often in mathematics or in several branches of science this is not originally due to Wilson. In fact, it is not at all due to Wilson. This was stated in 10th century AD. John Wilson is a mathematician from 18th century. This was known in 10th century AD and in fact, Wilson did not solve this at all. Wilson's teacher Edward Waring he gave this as a problem. He computed this p minus 1 factorial for several primes and he noticed that this is congruent to minus 1 mod p. So, as it is very common with teachers Edward Waring gave it as a problem to John Wilson to show that p minus 1 factorial is congruent to minus 1 mod p for every prime. But Wilson could not do it. However, it was Lagrange who did it in the next year 1771. But since it was Wilson who made it well known who posed this as a problem when he received it from Edward Waring and because he could not solve it he asked people and so it came to be known as Wilson's theorem. The proof of this is very easy and it will draw upon the thing that we have done earlier that the square roots of 1 in z mod pz when p is prime are only 1 and minus 1. Remember those calculations or remember that result that is a result that we are going to use here. So, we go towards proving this statement that p minus 1 factorial is congruent to minus 1 modulo p. So, note first a equal to 1 and minus 1 are the only solutions a square or we should perhaps say x square congruent to 1 mod p. So, what it means to say is the following. Thus, if you have a from this zp or zp and you take a to be different from 1 and minus 1 then the solution to ax equal to 1 in zp has or the solution to ax equal to 1 in zp is not equal to a. Let us think about this statement again. We start with a non-zero element in zp. So, we are looking at elements 1, 2, 3, 4 all the way up to p minus 1. We fix 1a from this set and we pose this question what is the solution to ax equal to 1. Now, this is same thing as solving ax congruent to 1 mod p and since you have taken p from 1 and p minus 1 the GCD of a and p is 1. Therefore, you have one solution and you actually have a unique solution. The only question we are interested in is whether this solution can be equal to a itself. We know that ax equal to 1 has a solution. So, we know that there is an element b again in zp such that a into b gives you 1. This is something that we have done quite often you know when we looked at a equal to 5 let us say and p equal to 7 and we wanted to solve for 5x congruent to 1 modulo 7. This had occurred in one of the solutions of linear equations, linear congruences or while solving the simultaneous systems of these. And we observed that 5 into 3 is 15 and 15 is congruent to 1 mod 7. So, the equation 5x equal to 1 in z7 has solution 3 which is different from 5. However, if you are looking for 6x equal to 1 modulo 7, 6 is itself the solution and the reason for that is 6 is equal to minus 1. If you were looking for solutions to x equal to 1 modulo p, x equal to 1 is the solution. So, when your coefficient a happens to be 1 or minus 1 that a is the only solution. But the previous analysis of looking for solutions of x square equal to 1 modulo p when p is odd prime told us that there are no other solutions. So, ax equal to 1 whenever a is different from 1 and minus 1 whenever there is a solution you will have that the solution is different from a. This is one thing that we keep in mind. There is another thing that we should remember. Further if b satisfies ax equal to 1 in gp then a satisfies bx equal to 1 in gp. So, you have earlier we have seen that ax equal to 1 has a solution other than a call that solution to be b. Then you can ask the same question for b. So, you have bx equal to 1. This is another solution that you have created that has solution to be the earlier a. So, going back to our example when we had 5x equal to 1 in g7 we noted that 3 was the solution. But then you ask if you ask for 3x equal to 1 in g7 5 will be the solution. So, all the numbers from 1 to p minus 1 other than 1 and minus 1 can be put in pairs where a will be put up with b where the property of a and b is that a into b is equal to 1 modulo gp. This is what we are going to do. Thus all of the elements I will not take 2. So, I will not take 1. So, I will start with 2, 3, 4, 5 up to p minus 2 can be paired a, b such that a, b equal to 1 in gp or a, b congruent to 1 modulo p. So, when I take the product p minus 1 factorial this is 1 into 2 into 3 and so on up to p minus 2 into p minus 1. So, these elements have been paired as a1 into b1 where a1 and b1 have the property that their product is 1 in gp a2 b2. So, on up to a, r, b, r. Remember this is an even set even number of elements. This is because your p is odd. So, 1 up to p minus 1 are even elements and you have removed 2 namely 1 and p minus 1 from them. So, what you get is an even number of elements and therefore they can be easily paired and finally we have this last element p minus 1. Note that all these products are 1 and finally we are left with p minus 1. Now we are almost there thus p minus 1 factorial equal to 1 into p minus 1 which is really minus 1 in the set gp or what we have is p minus 1 factorial is congruent to minus 1 mod p when p is an odd prime. So, the proof is quite simple but remember that the intricate analysis that we have done for the number of x square equal to 1 modulo n is one of the major steps behind the simplicity of this proof. So, we have such a nice result and you may ask what would happen in general. So, clearly Wilson's theorem does not hold in general. In fact, what that means is that if you take a number n which is not a prime, you may ask you know earlier equation slide said that p is odd if you put p equal to 2 then yes that also holds p equal to 2 here p minus 1 is minus 1 but that is also 1 modulo 2. So, there is actually no statement for p equal to 2 but we may say that p minus 1 factorial congruent to minus 1 holds for all primes that is something that we can say and when we ask for the same question whether it holds in general we are asking for a number which is not a prime. You may look for n equal to 4 and you will see that n minus 1 factorial which in the case of n equal to 4 is 3 factorial. 3 factorial is even number so clearly it cannot be minus 1 modulo 4. So, you already have that whenever n is not a prime that n is a composite number and then the smallest composite number 4 gives you that the equation does not hold. In fact, you can say more we will say so if n is not prime if n is not a prime then it has a factor which is not equal to 1 and not equal to n by the very definition of primes but you can also get that factor to be itself a prime. So, when you have this factor and if you have that n divides n minus 1 factorial plus 1 which is to say that this equation holds instead of not holding then q divides this because q divides n but q is less than n so q is less than or equal to n minus 1 so you have that q also divides n minus 1 factorial this will be 1 into 2 into dot dot dot somewhere q will have to appear and then you go up to n minus 1 and this is the contradiction. You have that q divides n minus 1 factorial and also that q divides n minus 1 factorial plus 1 that cannot happen. So, on one hand you have this on the other hand you have this which is not possible. So, clearly whenever n is not a prime we do not have Wilson's theorem but in fact something more can be said in fact if you have that n is not a prime then almost always we will have that n minus 1 factorial is 0 mod n n will divide n minus 1 factorial. This is something that always holds except 1 or 2 exceptions. So, I will what I will now give this to you as an exercise I will not give you the solution neither will I give you any hint to solve this problem. Take this as an exercise and find the exceptions. By exceptions I mean the situations where you do not have it to be 0 mod n. So, almost always is not the same as always almost always means except for a few cases you have this. So, those few cases where n is a composite number but n minus 1 factorial is not divisible by n those are the composite those are the cases that I want you to find and in the remaining cases I want you to prove that n minus 1 factorial is congruent to 0 mod n. So, this tells us that there is something very special which happens when n is a prime number the arithmetic in G p has some special properties compared to the arithmetic in a general G n. So, what does it mean let us go through these things once again if you are looking at linear congruences modulo a prime number then we see that the congruence A x congruent to b mod p has a solution when a comma p is 1. Now, p has the property that when you look at G p only the 0 is the one which does not have G cd equal to 1 with p but all other numbers have G cd equal to 1 with p and therefore, A x equal to b mod p will have solution whenever A is not 0 in G p if you have p dividing A but p and of course when because the G cd is 1 we have a unique solution further if you have p dividing A but p does not divide b then there are no solutions. So, you will have 0 x equal to a non 0 b congruent to p cannot give you a solution if you have that p divides A and p divides b then everything is a solution because this is like asking for 0 x equal to 0 mod p and whenever you put anything for x you are going to get the answer to be 0. So, barring the cases where p divides A the interesting cases are where p does not divide A or when you are looking at the elements in G p you are looking at the case where A is not equal to 0 whenever A is not equal to 0 the congruence A x equal to b has a unique solution. This is something which happens for complex numbers this is something which happens for real numbers this is something which happens for rational numbers also. So, whenever you have any complex number A and a complex number b and you ask for A x equal to b if the complex number A is not 0 you can simply invert that and you have the solution x equal to b upon A or x equal to b into A inverse or A inverse into b the multiplication is commutative. Then we would say that alright for G p there are things which are happening like the complex numbers or real numbers but for complex numbers and real numbers you have one more interesting thing that is that when you have a degree D polynomial any such polynomial will have at most D roots this is something that we have again used this is called the fundamental theorem of algebra. It says that if you are looking at a polynomial in degree D in one variable over complex numbers it has exactly D roots if you are looking at a polynomial over R you may have a smaller number of roots because some of these roots will actually be in C they will not show up when you look at only R. So, for R or for Q the rational numbers the correct statement of the theorem says that a polynomial in degree D has at most D roots you may have a smaller number of roots or you will have it to be equal to D but you will never have it to be more than D. The condition is that the polynomial should be a degree D polynomial does the similar theorem hold for G p that is the question and yes it does hold for G p and the theorem is theorem due to Lagrange you will see that Lagrange has done quite a bit of fundamental work in number 3 among other areas of mathematics and this is also a theorem due to him. So, he says that if you start with a polynomial of degree D over G p over G p means that you have coefficients coming from G p that is what it means then any such polynomial has at most D solutions in G p. Before we go to the proof we wonder what would happen when you have other cases or is there anything that we need to be careful about. So, number 1 note that the number of roots can be smaller than D. So, there are indeed examples where the number of roots can be smaller than D. For instance if you are looking at x raised to 4 congruent to 1 or to say it in other words if you are looking at the polynomial x to the 4 minus 1 in let us say G 2 this has only one root namely x equal to 1. But here you may say that G 2 actually has only 2 elements 0 and 1 0 to the 4 is 0 and 1 to the 4 is 1. So, that the fact that there are smaller than 4 roots you have only one root which is smaller than 4 is not very striking because G 2 alone has elements which are smaller than 4. So, if you are looking at a polynomial of degree D which is the degree being bigger than P then it should not be surprising that you have the number of roots to be smaller than P. So, if I give you an example I should give you an example where the prime P is bigger than the degree and yet we have smaller number of roots and so we will look at x square plus 1 in let us say G 7 has no root. So, x square plus 1 in G 7 has no roots you can actually quite quickly check this you have 0, 1, 2, 3, 4, 5 and 6 and let us just compute their squares. So, 0 square is 0, 1 square is 1, 2 square is 4, 3 square is 9 which is 2 and 4 is minus 3 so its square is 2, 5 is minus 2 so its square is 4 and 6 is minus 1 so its square is 1. So, there is no solution to x square plus 1, x square plus 1 is same as x square minus 6 when you are looking at G 7. So, there are no solutions at all your degree of the equation is 2 your number of elements is G 7 is 7 you could have had 2 solutions 1 solution but this solution this equation has no solution. So, this is indeed an instance where the number of roots is smaller than the degree D. What if we work with something which is not a prime does this result still count does this result still hold? No, it is important that you work modulo of prime. If you take n equal to 8 and we have solved the equation x square congruent to 1 mod 8. So, x square minus 1 in G 8 has 4 solutions 1, 3, 5 and 7 you have 4 solutions which is bigger than the degree. So, indeed it is very much important that you work modulo of prime if you work modulo a composite number then Lagrange's theorem need not hold. We will see a very simple proof of Lagrange's theorem in the next lecture and then we will do some more analysis with the set G P. So, I hope to see you again in the next lecture. Thank you very much.