reserve i,j,n,n1,n2,m,k,l,u for Nat,
        r,r1,r2 for Real,
        x,y for Integer,
        a,b for non trivial Nat,
        F for XFinSequence,
        cF,cF1,cF2 for complex-valued XFinSequence,
        c,c1,c2 for Complex;
reserve x,y,x1,u,w for Nat;
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,d,f for Integer;

theorem Th31:
  for i1,i2 st n<>0 holds {p: p.i1 = p.i2!}
    is diophantine Subset of n -xtuples_of NAT
proof
  let i1,i2;set n6=n+6;
  defpred R[XFinSequence of NAT] means $1.i1 = $1.i2!;
  set RR = {p: R[p] };
 assume A1: n<>0;
    n=n+0;then
    reconsider Y=i1,X=i2,N=n,Y1=n+1,Y2=n+2,Y3=n+3,X1=n+4,X2=n+5
      as Element of n+6 by HILB10_3:2,3;
    defpred P1[XFinSequence of NAT] means $1.Y1=($1.X2) |^($1.X1);
A2: {p where p is n6-element XFinSequence of NAT:P1[p]}
      is diophantine Subset of n6 -xtuples_of NAT by HILB10_3:24;
    defpred P2[XFinSequence of NAT] means $1.Y2=($1.N) |^($1.X);
A3: {p where p is n6-element XFinSequence of NAT:P2[p]}
      is diophantine Subset of n6 -xtuples_of NAT by HILB10_3:24;
    defpred P3[XFinSequence of NAT] means
      $1.N >= $1.X & $1.Y3=($1.N) choose ($1.X);
A4: {p where p is n6-element XFinSequence of NAT:P3[p]}
       is diophantine Subset of n6 -xtuples_of NAT by Th30;
    defpred P4[XFinSequence of NAT] means
      1*$1.Y=[\(1*$1.Y2)/(1*$1.Y3)/] & 1*$1.Y3 <>0;
A5: {p where p is n6-element XFinSequence of NAT:P4[p]}
        is diophantine Subset of n6 -xtuples_of NAT by Th28;
    defpred P5[XFinSequence of NAT] means 1*$1.X2=2 * $1.X+0;
A6: {p where p is n6-element XFinSequence of NAT:P5[p]}
        is diophantine Subset of n6 -xtuples_of NAT by HILB10_3:6;
    defpred P6[XFinSequence of NAT] means 1*$1.X1= 1*$1.X+1;
A7: {p where p is n6-element XFinSequence of NAT:P6[p]}
        is diophantine Subset of n6 -xtuples_of NAT by HILB10_3:6;
    defpred P7[XFinSequence of NAT] means 1*$1.N > 1*$1.Y1+0;
A8: {p where p is n6-element XFinSequence of NAT:P7[p]}
        is diophantine Subset of n6 -xtuples_of NAT by HILB10_3:7;
    defpred P12[XFinSequence of NAT] means P1[$1] & P2[$1];
A9: {p where p is n6-element XFinSequence of NAT:P12[p]}
        is diophantine Subset of n6 -xtuples_of NAT from HILB10_3:sch 3(A2,A3);
    defpred P123[XFinSequence of NAT] means P12[$1] & P3[$1];
A10: {p where p is n6-element XFinSequence of NAT:P123[p]}
        is diophantine Subset of n6 -xtuples_of NAT
      from HILB10_3:sch 3(A9,A4);
    defpred P1234[XFinSequence of NAT] means P123[$1] & P4[$1];
A11: {p where p is n6-element XFinSequence of NAT:P1234[p]}
        is diophantine Subset of n6 -xtuples_of NAT
      from HILB10_3:sch 3(A10,A5);
    defpred P12345[XFinSequence of NAT] means P1234[$1] & P5[$1];
A12: {p where p is n6-element XFinSequence of NAT:P12345[p]}
        is diophantine Subset of n6 -xtuples_of NAT
      from HILB10_3:sch 3(A11,A6);
    defpred P123456[XFinSequence of NAT] means P12345[$1] & P6[$1];
A13: {p where p is n6-element XFinSequence of NAT:P123456[p]}
        is diophantine Subset of n6 -xtuples_of NAT
      from HILB10_3:sch 3(A12,A7);
    defpred P1234567[XFinSequence of NAT] means P123456[$1] & P7[$1];
    set PP = {p where p is n6-element XFinSequence of NAT:P1234567[p]};
A14: PP is diophantine Subset of n6 -xtuples_of NAT
      from HILB10_3:sch 3(A13,A8);
    reconsider
    PPn = {p | n where p is n6-element XFinSequence of NAT: p in PP} as
       diophantine Subset of n -xtuples_of NAT by NAT_1:11,HILB10_3:5,A14;
A15: PPn c= RR
    proof
      let x be object; assume x in PPn;
      then consider p be n6-element XFinSequence of NAT such that
A16:    x= p|n & p in PP;
      ex q be n6-element XFinSequence of NAT st q=p & P1234567[q] by A16;
      then
A17:     p.Y = (p.X)! by Th18;
      (p|n).X = p.i2 & (p|n).Y = p.i1 by A1,HILB10_3:4;
      hence thesis by A17,A16;
    end;
    RR c= PPn
    proof
      let x be object; assume x in RR;
      then consider p such that
A18:     x=p & R[p];
      consider N,y1,y2,y3 be Nat such that
A19:     y1=(2*p.i2) |^(p.i2+1) & y2 = N|^(p.i2) & y3 = N choose (p.i2) &
      N > y1 & p.i1=[\y2/y3/] by Th18,A18;
A20:  p.i2 <>0 implies N>= p.i2
      proof
        assume p.i2 <>0;
        then
A21:      2* p.i2 >=1 by NAT_1:14;
        p.i2+1 >=1 by NAT_1:11;
        then
A22:      (2*p.i2) |^(p.i2+1) >= (2*p.i2)|^1 by A21,PREPOWER:93;
        N > 2*p.i2 & p.i2+p.i2 >= p.i2 by A22,A19,XXREAL_0:2,NAT_1:11;
        hence thesis by XXREAL_0:2;
      end;
      reconsider x1=p.i2+1,x2=2*p.i2 as Element of NAT;
      reconsider N,y1,y2,y3 as Element of NAT by ORDINAL1:def 12;
      set Y = <%N%>^<%y1%>^<%y2%>^<%y3%>^<%x1%>^<%x2%>;
      set PY = p ^ Y;
A23:  len p = n & len Y = 6 by CARD_1:def 7;
A24:  PY|n =p by A23,AFINSQ_1:57;
      0 in dom Y by AFINSQ_1:66;
      then
A25:  PY.(n+0) = Y.0 by A23,AFINSQ_1:def 3
         .= N by AFINSQ_1:47;
      1 in dom Y by A23,AFINSQ_1:66;
      then
A26:  PY.(n+1) = Y.1 by A23,AFINSQ_1:def 3
        .= y1 by AFINSQ_1:47;
      2 in dom Y by A23,AFINSQ_1:66;
      then
A27:  PY.(n+2) = Y.2 by A23,AFINSQ_1:def 3
        .= y2 by AFINSQ_1:47;
      3 in dom Y by A23,AFINSQ_1:66;
      then
A28:  PY.(n+3) = Y.3 by A23,AFINSQ_1:def 3
        .= y3 by AFINSQ_1:47;
      4 in dom Y by A23,AFINSQ_1:66;
      then
A29:  PY.(n+4) = Y.4 by A23,AFINSQ_1:def 3
        .= x1 by AFINSQ_1:47;
      5 in dom Y by A23,AFINSQ_1:66;
      then
A30:  PY.(n+5) = Y.5 by A23,AFINSQ_1:def 3
        .= x2 by AFINSQ_1:47;
      P1234567[PY]
        by A20,A19,CATALAN2:26,A24,A1,HILB10_3:4,A25,A26,A27,A28,A29,A30;
      then PY in PP;
      hence thesis by A24,A18;
    end;
    hence thesis by A15,XBOOLE_0:def 10;
end;
