reserve i,i1,i2,i3,i4,i5,j,r,a,b,x,y for Integer,
  d,e,k,n for Nat,
  fp,fk for FinSequence of INT,
  f,f1,f2 for FinSequence of REAL,
  p for Prime;
reserve fr for FinSequence of REAL;
reserve fr,f for FinSequence of INT;
reserve b,m for Nat;
reserve b for Integer;
reserve m for Integer;
reserve fp for FinSequence of NAT;

theorem Th36:
  p>2 implies Lege (-1,p) = (-1)|^((p-'1) div 2)
proof
  assume
A1: p>2;
  |.(-1)|^((p-'1) div 2).| = 1 by SERIES_2:1;
  then
A2: (-1)|^((p-'1) div 2) =1 or -(-1)|^((p-'1) div 2) =1 by ABSVALUE:1;
  (-1) gcd p = |.(-1)|^1.| gcd |.p.| by INT_2:34
    .= 1 gcd |.p.| by SERIES_2:1
    .= 1 by NEWTON:51;
  then
A3: Lege (-1,p),(-1)|^((p-'1) div 2) are_congruent_mod p by A1,Th28;
  per cases by A2;
  suppose
A4: (-1)|^((p-'1) div 2) = 1;
    then
A5: p divides (Lege (-1,p) - 1) by A3;
A6: now
      assume Lege(-1,p) = -1;
      then p divides -2 by A5;
      then p divides 2 by INT_2:10;
      hence contradiction by A1,NAT_D:7;
    end;
    now
      assume Lege(-1,p) = 0;
      then p divides 1 by A5,INT_2:10; then
      p <= 1 by NAT_D:7; then
      p < 1+1 by NAT_1:13;
      hence contradiction by A1;
    end;
    hence thesis by A4,Th25,A6;
  end;
  suppose
A7: (-1)|^((p-'1) div 2) = -1;
    then A8: p divides (Lege (-1,p) - (-1)) by A3;
    then A9: Lege(-1,p) <> 1 by A1,NAT_D:7;
    now
      assume Lege(-1,p) = 0; then
      p <= 1 by A8,NAT_D:7; then
      p < 1+1 by NAT_1:13;
      hence contradiction by A1;
    end;
    hence thesis by A7,Th25,A9;
  end;
end;
