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;
reserve a,m for Nat;
reserve f,g,h,k for FinSequence of REAL;
reserve X for finite set,
  F for FinSequence of bool X;
reserve q for Prime;

theorem
  p>2 & q>2 & p<>q & (p mod 4 = 1 or q mod 4 = 1) implies Lege(p,q) = Lege(q,p)
proof
  assume that
A1: p>2 and
A2: q>2 and
A3: p<>q and
A4: p mod 4 = 1 or q mod 4 = 1;
  p>1 by INT_2:def 4;
  then
A5: p-'1 = p-1 by XREAL_1:233;
  q>1 by INT_2:def 4;
  then
A6: q-'1 = q-1 by XREAL_1:233;
  per cases by A4;
  suppose
    p mod 4 = 1;
    then p=4*(p div 4)+1 by NAT_D:2;
    then p-'1 = 2*(2*(p div 4)) by A5;
    then (p-'1) div 2 = 2*(p div 4);
    then
A7: Lege(p,q)*Lege(q,p) = (-1)|^((2*(p div 4))*((q-'1) div 2)) by A1,A2,A3,Th49
      .= ((-1)|^(2*(p div 4)))|^((q-'1) div 2) by NEWTON:9
      .= (((-1)|^2)|^(p div 4))|^((q-'1) div 2) by NEWTON:9
      .= ((1|^2)|^(p div 4))|^((q-'1) div 2) by WSIERP_1:1
      .= 1;
    per cases by Th25;
    suppose
      Lege(p,q)=1;
      hence thesis by A7;
    end;
    suppose
      Lege(p,q)=0;
      hence thesis by A7;
    end;
    suppose
      Lege(p,q)=-1;
      hence thesis by A7;
    end;
  end;
  suppose
    q mod 4 = 1;
    then q=4*(q div 4)+1 by NAT_D:2;
    then q-'1 = 2*(2*(q div 4)) by A6;
    then (q-'1) div 2 = 2*(q div 4);
    then
A8: Lege(p,q)*Lege(q,p) = (-1)|^((2*(q div 4))*((p-'1) div 2)) by A1,A2,A3,Th49
      .= ((-1)|^(2*(q div 4)))|^((p-'1) div 2) by NEWTON:9
      .= (((-1)|^2)|^(q div 4))|^((p-'1) div 2) by NEWTON:9
      .= ((1|^2)|^(q div 4))|^((p-'1) div 2) by WSIERP_1:1
      .= 1;
    per cases by Th25;
    suppose
      Lege(p,q)=1;
      hence thesis by A8;
    end;
    suppose
      Lege(p,q)=0;
      hence thesis by A8;
    end;
    suppose
      Lege(p,q)=-1;
      hence thesis by A8;
    end;
  end;
end;
