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 Th22:
  0 < i <= n & 0 <= j < 4*n & Px(a,i),Px(a,j) are_congruent_mod Px(a,n)
    implies j = i or j + i = 4*n
proof
  set P=Px(a,n);
  assume
A1: 0 < i <= n & 0 <= j < 4*n & Px(a,i),Px(a,j) are_congruent_mod P;
  then
A2: Px(a,j),Px(a,i) are_congruent_mod P by INT_1:14;
  reconsider j4n = 4*n-j as Nat by A1,NAT_1:21;
  Px(a,|.4*n+-j4n.|), Px(a,|.-j4n.|) are_congruent_mod Px(a,|.n.|) by Th18;
  then
A3: Px(a,i),Px(a,j4n) are_congruent_mod P by A1,INT_1:15;
  then
A4: Px(a,j4n),Px(a,i) are_congruent_mod P by INT_1:14;
  n<= n+n by NAT_1:11;
  then
A5: i<= n+n by A1,XXREAL_0:2;
  per cases;
  suppose
A6:   j <= 2*n;
    per cases;
    suppose i <=j;
      hence thesis by A6,Th21,A1;
    end;
    suppose j < i;
      then (j=0 & i = 2 & a=2 & n=1) or j=i by A6,Th21,A5,A2;
      hence thesis by A1;
    end;
  end;
  suppose
A7:   j > 2*n;
    then
A8:   j4n < 4*n-2*n by XREAL_1:10;
    per cases;
    suppose
      i <=j4n;
      then i=j4n by A3,A8,Th21,A1;
      hence thesis;
    end;
    suppose j4n < i;
      then (j4n=0 & i = 2 & a=2 & n=1) or j4n=i by A4,A7,Th21,A5;
      hence thesis by A1;
    end;
  end;
end;
