reserve i,s,t,m,n,k for Nat,
        c,d,e for Element of NAT,
        fn for FinSequence of NAT,
        x,y for Integer;
reserve p for Prime;

theorem Th14:
  n>1 & i,n are_coprime
    implies order(i|^s,n) = order(i,n) div (order(i,n) gcd s)
proof assume A1:n>1 & i,n are_coprime;
   then A2:i <> 0 & n <> 0 by Th5;
   i gcd n = 1 by A1,INT_2:def 3;then
   i|^s gcd n = 1 by A2,NAT_4:10;then
A3:i|^s,n are_coprime by INT_2:def 3;
A4:order(i,n) > 0 by A1,PEPIN:def 2;
  set K1 = order(i,n) gcd s,
      K2 = order(i,n) div K1;
  per cases;
  suppose A5:s = 0;
   then K1 = order(i,n) by NEWTON:52;
   then A6:K2 = 1 by A4,NAT_2:3;
   i|^s = 1 by A5,NEWTON:4;
   hence thesis by A1,A6,PEPIN:46;
  end;
  suppose A7:s > 0;
    K1 divides order(i,n) & K1 divides s by NAT_D:def 5; then
A8: order(i,n) = K2 * K1 & s = (s div K1) * K1 by NAT_D:3; then
A9:K2 <> 0 & K1 <> 0 & (s div K1) <> 0 by A1,A7,PEPIN:def 2;
A10: K2,(s div K1) are_coprime by A8,A9,EULER_1:6;
     s * K2 = (s div K1) * order(i,n) by A8;
     then order(i,n) divides s * K2 by NAT_D:def 3;
     then (i|^(s * K2)) mod n = 1 by A1,PEPIN:48;
     then A11:(i|^s|^K2) mod n = 1 by NEWTON:9;
    for k be Nat st k > 0 & (i|^s|^k) mod n = 1 holds K2 <= k
  proof let k be Nat;
   reconsider k1=k as Element of NAT by ORDINAL1:def 12;
    assume A12:k > 0 & (i|^s|^k) mod n = 1;
    then (i|^(s*k)) mod n = 1 by NEWTON:9;
    then (K2 * K1) divides (((s div K1) * k1) * K1) by A8,A1,PEPIN:47;
    then K2 divides ((s div K1) * k1) by A9,PYTHTRIP:7;
   hence thesis by A12,A10,PEPIN:3,NAT_D:7;
  end;
 hence thesis by A1,A3,A9,A11,PEPIN:def 2;
 end;
end;
