reserve d,i,j,k,m,n,p,q,x,k1,k2 for Nat,
  a,c,i1,i2,i3,i5 for Integer;

theorem Th39:
  for n st n > 1 holds m mod n = 1 iff m,1 are_congruent_mod n
proof
  let n;
  assume
A1: n > 1;
A2: m,1 are_congruent_mod n implies m mod n = 1
  proof
    assume m,1 are_congruent_mod n;
    then consider t being Integer such that
A3: n*t = m - 1;
    reconsider m,n as Integer;
    m mod n = (n*t + 1) mod n by A3
      .= 1 mod n by NAT_D:61;
    hence thesis by A1,NAT_D:14;
  end;
  m mod n = 1 implies m,1 are_congruent_mod n
  proof
    assume m mod n = 1;
    then consider k being Nat such that
A4: m = n*k + 1 and
    1 < n by NAT_D:def 2;
    n*k = m - 1 by A4;
    hence thesis;
  end;
  hence thesis by A2;
end;
