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;
 reserve fp,fr for FinSequence of NAT;

theorem
  n>1 & s,n are_coprime & s*t mod n = 1
    implies order(s,n)=order(t,n)
proof assume A1:n>1 & s,n are_coprime & s*t mod n = 1;
   set f = t gcd n;
A2: now assume not t,n are_coprime;
       then A3:f <> 1 by INT_2:def 3;
       f <> 0 by A1,INT_2:5;
       then A4:f > 1 by A3,NAT_1:25;
A5:    n divides (s*t - 1) by A1,PEPIN:8;
A6:    f divides t & f divides n by NAT_D:def 5;then
A7:    f divides (s*t - 1) by A5,INT_2:9;
       f divides s*t by A6,NAT_D:9;
     hence contradiction by A4,A7,INT_5:2,NAT_D:7;
    end;
A8:order(s,n)>0 by A1,PEPIN:def 2;
    set M=s*t;
A9:M mod n = 1 mod n by A1,PEPIN:5;
    then M|^order(s,n) mod n = 1|^order(s,n) mod n by INT_4:8
                  .= 1 mod n  .= 1 by A1,PEPIN:5;
    then A10:(s|^order(s,n)*t|^order(s,n)) mod n = 1 by NEWTON:7;
    s|^order(s,n) mod n = 1 by A1,PEPIN:def 2;then
A11:t|^order(s,n) mod n = 1 by A10,Th6;
    for k be Nat st k > 0 & (t|^k) mod n = 1 holds order(s,n) <= k
    proof let k be Nat;
      assume A12:k > 0 & (t|^k) mod n = 1;
      M|^k mod n = 1|^k mod n by A9,INT_4:8
                .= 1 mod n  .= 1 by A1,PEPIN:5;
      then (s|^k * t|^k) mod n = 1 by NEWTON:7;
      then s|^k mod n = 1 by A12,Th6;
     hence thesis by A1,A12,PEPIN:def 2;
    end;
  hence thesis by A11,A8,A2,A1,PEPIN:def 2;
end;
