
theorem Th18:
  for p being Prime,
      x being Integer
  holds x|^2, 1 are_congruent_mod p iff
        (x, 1 are_congruent_mod p or x, -1 are_congruent_mod p)
proof
  let p be Prime,
      x be Integer;
A1: now assume x|^2, 1 are_congruent_mod p;
   then p divides (x^2 - 1^2) by NEWTON:81;
   then A2: p divides (x+1) * (x-1);
   now per cases by A2,Th7;
   case p divides x+1;
      then consider l being Integer such that
      A3: p * l = x + 1;
      thus x,-1 are_congruent_mod p by A3;
      end;
   case p divides x-1;
      then consider l being Integer such that
      A4: p * l = x - 1;
      thus x,1 are_congruent_mod p by A4;
      end;
   end;
   hence x,1 are_congruent_mod p or x,-1 are_congruent_mod p;
   end;
now assume A5: x,1 are_congruent_mod p or x,-1 are_congruent_mod p;
  now per cases by A5;
  case x,1 are_congruent_mod p;
     then x*x,1*1 are_congruent_mod p by INT_1:18;
     hence x|^2, 1 are_congruent_mod p by NEWTON:81;
     end;
  case x,-1 are_congruent_mod p;
     then x*x,(-1)*(-1) are_congruent_mod p by INT_1:18;
     hence x|^2, 1 are_congruent_mod p by NEWTON:81;
     end;
  end;
  hence x|^2, 1 are_congruent_mod p;
  end;
hence thesis by A1;
end;
