reserve n for Nat,
        i,j,i1,i2,i3,i4,i5,i6 for Element of n,
        p,q,r for n-element XFinSequence of NAT;
reserve i,j,n,n1,n2,m,k,l,u,e,p,t for Nat,
        a,b for non trivial Nat,
        x,y for Integer,
        r,q for Real;

theorem Th21:
  i <= j <= 2*n & Px(a,i),Px(a,j) are_congruent_mod Px(a,n)
      implies (i=0 & j = 2 & a=2 & n=1) or i=j
proof
  set P=Px(a,n);
  assume
A1: i <= j <= 2*n & Px(a,i),Px(a,j) are_congruent_mod P
    & not (i=0 & j = 2 & a=2 & n=1) & i<>j;
  reconsider j2n = 2*n-j as Nat by A1,NAT_1:21;
A2:  0,P are_congruent_mod P by INT_1:12;
A3:  i <= 2*n by A1,XXREAL_0:2;
  i<n or i=n or n <i by XXREAL_0:1;
  then per cases by A1,XXREAL_0:1,2;
  suppose i < n & j < n;
    hence thesis by A1,Lm8;
  end;
  suppose
A4:   i < n & j = n;
    then P,Px(a,i) are_congruent_mod P by A1,INT_1:14;
    then
A5:   P-P,Px(a,i) are_congruent_mod P by INT_1:22;
    Px(a,i) <P by A4,Th19;
    then 0 = Px(a,i) by A5,Lm7;
    hence thesis;
  end;
  suppose
A6:  i < n & j > n;
    2*n + -j2n = j;
    then Px(a,|.j.|),- Px(a,|.-j2n.|) are_congruent_mod Px(a,|.n.|) by Th17;
    then Px(a,|.i.|),-Px(a,j2n) are_congruent_mod P by A1,INT_1:15;
    then
A7:   Px(a,|.i.|)+0,-Px(a,j2n)+P are_congruent_mod P by A2,INT_1:16;
A8:   2*n-j < 2*n-n by A6,XREAL_1:15;
    then reconsider  Pj=P- Px(a,j2n) as Nat by NAT_1:21,HILB10_1:10;
A9:   Px(a,i) < P by A6,Th19;
    Pj < P-0 by XREAL_1:15;
    then
A10:  Px(a,i) = Pj by A9,A7,Lm7;
    per cases;
    suppose not (a=2 & n=1);
      then Px(a,i) < P/2 & Px(a,j2n) < P/2 by A6,A8,Lm9;
      then Px(a,i) +Px(a,j2n) < P/2 +P/2 = P by XREAL_1:8;
      hence thesis by A10;
    end;
    suppose
A11:    a=2 & n=1;
      then i=0 & j >= 1+1 by A6,NAT_1:13,14;
      hence thesis by A1,A11,XXREAL_0:1;
    end;
  end;
  suppose
A12:  i = n & j >n;
    2*n + -j2n = j;
    then Px(a,|.j.|),- Px(a,|.-j2n.|) are_congruent_mod Px(a,|.n.|) by Th17;
    then P,-Px(a,j2n) are_congruent_mod P by A12,A1,INT_1:15;
    then P+0,-Px(a,j2n)+P are_congruent_mod P by A2,INT_1:16;
    then
A13:  P-P,-Px(a,j2n)+P are_congruent_mod P by INT_1:22;
    2*n-j <= 2*n-n by A12,XREAL_1:15;
    then reconsider  Pj=P- Px(a,j2n) as Nat by NAT_1:21,HILB10_1:10;
    Pj < P-0 by XREAL_1:15;
    then 0 = Pj by A13,Lm7;
    then 2*n-j = n by Th20;
    hence thesis by A12;
  end;
  suppose i > n & j >n;
    hence thesis by A1,Lm10,A3;
  end;
end;
