reserve n,m,k for Nat,
        p,q for n-element XFinSequence of NAT,
        i1,i2,i3,i4,i5,i6 for Element of n,
        a,b,c,d,e for Integer;

theorem Th23:
  for i1,i2,i3 holds
    {p: p.i1 = Py(p.i2,p.i3) & p.i2 > 1}
         is diophantine Subset of n -xtuples_of NAT
proof
  let i1,i2,i3;
  set n9=n+9;
  set WW = {p:  p.i1 = Py(p.i2,p.i3) & p.i2 > 1};
  WW c= n -xtuples_of NAT
  proof
    let y be object;
    assume y in WW;
    then ex p st
    y=p & p.i1 = Py(p.i2,p.i3) & p.i2 > 1;
    hence thesis by HILB10_2:def 5;
  end;
  then reconsider WW as Subset of n -xtuples_of NAT;
  per cases;
  suppose n=0;
    then WW is diophantine Subset of n -xtuples_of NAT;
    hence thesis;
  end;
  suppose A1: n<>0;
    n=n+0;then
    reconsider N=n,I1=i1,I2=i2,I3=i3,N1=n+1,N2=n+2,N3=n+3,N4=n+4,N5=n+5,
    N6=n+6,N7=n+7,N8=n+8 as Element of n9 by Th2,Th3;
    defpred P0[XFinSequence of NAT] means 1*$1.I2 > 0*$1.I1  + 1;
    A2: {p where p is n9-element XFinSequence of NAT:P0[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th7;
    defpred P1[XFinSequence of NAT] means [1* $1.N,1*$1.I1]
    is Pell's_solution of (((1*$1.I2)^2) -' 1);
    A3: {p where p is n9-element XFinSequence of NAT:P1[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th22;
    defpred P2[XFinSequence of NAT] means [1* $1.N1,1*$1.N2]
    is Pell's_solution of (((1*$1.I2)^2) -' 1);
    A4: {p where p is n9-element XFinSequence of NAT:P2[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th22;
    defpred P3[XFinSequence of NAT] means 1*$1.N2 >= 1*$1.I1 + 0;
    A5: {p where p is n9-element XFinSequence of NAT:P3[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th8;
    defpred P4[XFinSequence of NAT] means 1*$1.N3 > 1*$1.I1 + 0;
    A6: {p where p is n9-element XFinSequence of NAT:P4[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th7;
    defpred P5[XFinSequence of NAT] means 1*$1.I1 >= 1*$1.I3 + 0;
    A7: {p where p is n9-element XFinSequence of NAT:P5[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th8;
    defpred P6[XFinSequence of NAT] means [1* $1.N4,1*$1.N5]
    is Pell's_solution of (((1*$1.N3)^2) -' 1);
    A8: {p where p is n9-element XFinSequence of NAT:P6[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th22;
    defpred P7[XFinSequence of NAT] means
    1*$1.N5, 1*$1.I1 are_congruent_mod 1*$1.N1 ;
    A9: {p where p is n9-element XFinSequence of NAT:P7[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th21;
    defpred PA[XFinSequence of NAT] means 1*$1.N3, 1*$1.I2
    are_congruent_mod 1*$1.N1 ;
    A10: {p where p is n9-element XFinSequence of NAT:PA[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th21;
    defpred PB[XFinSequence of NAT] means 1*$1.N5, 1*$1.I3
    are_congruent_mod 1*$1.N6;
    A11: {p where p is n9-element XFinSequence of NAT:PB[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th21;
    defpred PC[XFinSequence of NAT] means
    1*$1.N3, 1*$1.N8 are_congruent_mod 1*$1.N6;
    A12: {p where p is n9-element XFinSequence of NAT:PC[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th21;
    defpred PD[XFinSequence of NAT] means 1*$1.N2,
    0*$1.N3 are_congruent_mod 1*$1.N7;
    A13: {p where p is n9-element XFinSequence of NAT:PD[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th21;
    defpred PE[XFinSequence of NAT] means 1 = $1.N8;
    A14: {p where p is n9-element XFinSequence of NAT:PE[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th14;
    defpred PF[XFinSequence of NAT] means 2*$1.I1 = $1.N6;
    A15: {p where p is n9-element XFinSequence of NAT:PF[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th12;
    defpred PG[XFinSequence of NAT] means 1*$1.I1*$1.I1 = 1*$1.N7;
    A16: {p where p is n9-element XFinSequence of NAT:PG[p]}
    is diophantine Subset of n9 -xtuples_of NAT by Th9;
    defpred P01[XFinSequence of NAT] means P0[$1] & P1[$1];
    defpred P23[XFinSequence of NAT] means P2[$1] & P3[$1];
    defpred P45[XFinSequence of NAT] means P4[$1] & P5[$1];
    defpred P67[XFinSequence of NAT] means P6[$1] & P7[$1];
    defpred PAB[XFinSequence of NAT] means PA[$1] & PB[$1];
    defpred PCD[XFinSequence of NAT] means PC[$1] & PD[$1];
    defpred PEF[XFinSequence of NAT] means PE[$1] & PF[$1];
    {p where p is n9-element XFinSequence of NAT : P0[p] &  P1[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A2,A3);
    then A17: {p where p is n9-element XFinSequence of NAT: P01[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : P2[p] &  P3[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A4,A5);
    then A18: {p where p is n9-element XFinSequence of NAT: P23[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : P4[p] &  P5[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A6,A7);
    then A19: {p where p is n9-element XFinSequence of NAT: P45[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : P6[p] &  P7[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A8,A9);
    then A20: {p where p is n9-element XFinSequence of NAT: P67[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PA[p] &  PB[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A10,A11);
    then A21: {p where p is n9-element XFinSequence of NAT: PAB[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PC[p] &  PD[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A12,A13);
    then A22: {p where p is n9-element XFinSequence of NAT: PCD[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PE[p] &  PF[p]}
    is diophantine Subset of n9 -xtuples_of NAT from
      IntersectionDiophantine(A14,A15);
    then A23: {p where p is n9-element XFinSequence of NAT: PEF[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    defpred P0123[XFinSequence of NAT] means P01[$1] & P23[$1];
    defpred P4567[XFinSequence of NAT] means P45[$1] & P67[$1];
    defpred PABCD[XFinSequence of NAT] means PAB[$1] & PCD[$1];
    defpred PEFG[XFinSequence of NAT] means PEF[$1] & PG[$1];
    {p where p is n9-element XFinSequence of NAT : P01[p] &  P23[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A17,A18);
    then A24: {p where p is n9-element XFinSequence of NAT: P0123[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : P45[p] &  P67[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A19,A20);
    then A25: {p where p is n9-element XFinSequence of NAT: P4567[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PAB[p] &  PCD[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A21,A22);
    then A26: {p where p is n9-element XFinSequence of NAT: PABCD[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PEF[p] &  PG[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A23,A16);
    then A27: {p where p is n9-element XFinSequence of NAT: PEFG[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    defpred P01234567[XFinSequence of NAT] means P0123[$1] & P4567[$1];
    defpred PABCDEFG[XFinSequence of NAT] means PABCD[$1] & PEFG[$1];
    {p where p is n9-element XFinSequence of NAT : P0123[p] &  P4567[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A24,A25);
    then A28: {p where p is n9-element XFinSequence of NAT: P01234567[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    {p where p is n9-element XFinSequence of NAT : PABCD[p] &  PEFG[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A26,A27);
    then A29: {p where p is n9-element XFinSequence of NAT: PABCDEFG[p]}
    is diophantine Subset of n9 -xtuples_of NAT;
    defpred P01234567ABCDEFG[XFinSequence of NAT] means
    P01234567[$1] & PABCDEFG[$1];
    A30:{p where p is n9-element XFinSequence of NAT :
      P01234567[p] &PABCDEFG[p]}
    is diophantine Subset of n9 -xtuples_of NAT
      from IntersectionDiophantine(A28,A29);
    set DD={p where p is n9-element XFinSequence of NAT: P01234567ABCDEFG[p]};
    set DDR = {p|n where p is n9-element XFinSequence of NAT:p in DD};
    A31: DDR is diophantine Subset of n -xtuples_of NAT by Th5,A30,NAT_1:11;
    A32: DDR  c= WW
    proof
      let o be object such that A33: o in DDR;
      consider p be n9-element XFinSequence of NAT such that
      A34: o=p|n & p in DD by A33;
      consider q be n9-element XFinSequence of NAT such that
      A35: p=q & P01234567ABCDEFG[q] by A34;
      len p = n9 & n9 >=n by CARD_1:def 7,NAT_1:11;
      then len (p|n)=n by AFINSQ_1:54;
      then reconsider pn =p|n as n-element XFinSequence of NAT by CARD_1:def 7;
      A36: pn.I3 = p.i3 & pn.I2 = p.i2 & (p|n).I1 = p.i1  by A1,Th4;
      1*p.I2 > 0*p.I1  + 1 & [1* p.N,1*p.I1]
      is Pell's_solution of (((1*p.I2)^2) -' 1) &
      [1* p.N1,1*p.N2] is Pell's_solution of (((1*p.I2)^2) -' 1)
      & 1*p.N2 >= 1*p.I1 + 0 &
      1*p.N3 > 1*p.I1 + 0 & 1*p.I1 >= 1*p.I3 + 0 &
      [1* p.N4,1*p.N5] is Pell's_solution of (((1*p.N3)^2) -' 1) &
      1*p.N5, 1*p.I1 are_congruent_mod 1*p.N1 & 1*p.N3, 1*p.I2
      are_congruent_mod 1*p.N1 &
      1*p.N5, 1*p.I3 are_congruent_mod 1*(2*p.I1) & 1*p.N3,
      1*1 are_congruent_mod 1*(2*p.I1) &
      1*p.N2, 0*p.N3 are_congruent_mod (p.I1)^2 by SQUARE_1:def 1,A35;
      then pn.i1 = Py(pn.i2,pn.i3) & pn.i2 > 1 by HILB10_1:38,A36;
      hence thesis by A34;
    end;
    WW c= DDR
    proof
      let o be object such that A37: o in WW;
      consider p such that
      A38:o=p &p.i1 = Py(p.i2,p.i3) & p.i2 > 1 by A37;
      set y = p.i1,a=p.i2,z=p.i3;
      consider x,x1,y1,A,x2,y2 be Nat such that
      A39: a>1 &
      [x,y] is Pell's_solution of (a^2-'1) &
      [x1,y1] is Pell's_solution of (a^2-'1)&
      y1>=y & A > y & y >= z &
      [x2,y2] is Pell's_solution of (A^2-'1) &
      y2,y are_congruent_mod x1 &
      A,a are_congruent_mod x1 &
      y2,z are_congruent_mod 2*y &
      A,1 are_congruent_mod 2*y &
      y1,0 are_congruent_mod y^2 by A38,HILB10_1:38;
      reconsider x,x1,y1,A,x2,y2 as Element of NAT by ORDINAL1:def 12;
      reconsider 2y=2*y as Element of NAT;
      reconsider yy=y*y as Element of NAT;
      reconsider Z=1 as Element of NAT;
      set Y=<%x%>^<%x1%>^<%y1%>^<%A%>^<%x2%>^<%y2%>^<%2y%>^<%yy%>^<%Z%>;
      set PY = p^Y;
      A40: len p = n & len Y = 9 by CARD_1:def 7;
      A41: PY|n =p by A40,AFINSQ_1:57;
      0 in dom Y by A40,AFINSQ_1:66;
      then A42:PY.(n+0) = (Y).0 by A40,AFINSQ_1:def 3
      .= x by AFINSQ_1:50;
      1 in dom Y by A40,AFINSQ_1:66;
      then A43:PY.(n+1) = (Y).1 by A40,AFINSQ_1:def 3
      .= x1 by AFINSQ_1:50;
      2 in dom Y by A40,AFINSQ_1:66;
      then A44:PY.(n+2) = (Y).2 by A40,AFINSQ_1:def 3
      .= y1 by AFINSQ_1:50;
      3 in dom Y by A40,AFINSQ_1:66;
      then A45: PY.(n+3) = Y.3 by A40,AFINSQ_1:def 3
      .= A by AFINSQ_1:50;
      4 in dom Y by A40,AFINSQ_1:66;
      then A46: PY.(n+4) = Y.4 by A40,AFINSQ_1:def 3
      .= x2 by AFINSQ_1:50;
      5 in dom Y by A40,AFINSQ_1:66;
      then A47: PY.(n+5) = Y.5 by A40,AFINSQ_1:def 3
      .= y2 by AFINSQ_1:50;
      6 in dom Y by A40,AFINSQ_1:66;
      then  PY.(n+6) = Y.6 by A40,AFINSQ_1:def 3
      .= 2y by AFINSQ_1:50;
      then A48: PY.N6 = 2*y = 2*PY.I1 by A41,A1,Th4;
      7 in dom Y by A40,AFINSQ_1:66;
      then A49: PY.(n+7) = Y.7 by A40,AFINSQ_1:def 3
      .= yy by AFINSQ_1:50;
      8 in dom Y by A40,AFINSQ_1:66;
      then A50: PY.(n+8) = Y.8 by A40,AFINSQ_1:def 3
      .= Z by AFINSQ_1:50;
      P01234567ABCDEFG[PY] by SQUARE_1:def 1,A39,A42,A45,A46,A47,A1,Th4, A43,
        A41,A50,A48,A49,A44;
      then PY in DD;
      hence thesis by A38,A41;
    end;
    hence thesis by A31,A32,XBOOLE_0:def 10;
  end;
end;
