
theorem Th17:
  for p being Prime,
      x being Element of Z/Z*(p),
      i being Integer,
      n being Nat
  st x = i holds x |^ n = (i |^ n) mod p
proof
let p be Prime,
    x be Element of Z/Z*(p), i be Integer,
    n be Nat;
assume A1: x = i;
A2: Z/Z*(p) = multMagma(#Segm0(p),multint0(p)#) by INT_7:def 4;
Segm0(p) = Segm(p) \ {0} by INT_2:def 4,INT_7:def 2;
then A3: i in Segm(p) by A2,A1,XBOOLE_0:def 5;
reconsider i as Element of NAT by A1,A2,INT_1:3;
defpred P[Nat] means
x |^ ($1) = (i |^ ($1)) mod p;
A4: x|^0 = 1_(Z/Z*(p)) by GROUP_1:25;
1 < p by INT_2:def 4;
then A5: 1 div p <= 1-1 by INT_1:56,INT_1:52;
A6: 1 div p = 0 by A5;
i|^0 = 1 by NEWTON:4;
then (i |^ 0) mod p = 1 - (1 div p) * p by INT_1:def 10;
then A7: P[0] by A4,A6,INT_7:21;
A8: now let k be Nat;
   assume A9: P[k];
   x |^ (k+1) = x|^k * x by GROUP_1:34
             .= ((i |^ k mod p) * i) mod p by A1,A9,Th16
             .= ((i |^ k mod p) * (i mod p)) mod p by A3,NAT_D:24,NAT_1:44
             .= (i |^ k * i) mod p by NAT_D:67
             .= (i |^ (k+1)) mod p by NEWTON:6;
   hence P[k+1];
   end;
A10: for k being Nat holds P[k] from NAT_1:sch 2(A7,A8);
thus thesis by A10;
end;
