reserve X for set;
reserve a,b,c,k,m,n for Nat;
reserve i,j for Integer;
reserve r,s for Real;
reserve p,p1,p2,p3 for Prime;

theorem
  { [x,y] where x,y is positive Nat : (x-1)^2+(x+1)^2 = y^2+1 } is infinite
  proof
    deffunc R(Nat,Nat) = ($1-1)^2+($1+1)^2 - ($2^2+1);
    set A = { [x,y] where x,y is positive Nat : R(x,y) = 0 };
A1: R(2,3) = 0;
    then [2,3] in A;
    then reconsider A as non empty set;
    deffunc p1(Nat,Nat) = 3*$1+2*$2+0;
    deffunc p2(Nat,Nat) = 4*$1+3*$2+0;
    defpred P[object,Element of [:NAT,NAT:],Element of [:NAT,NAT:]] means
    $3 = [p1($2`1,$2`2),p2($2`1,$2`2)];
    set f = recSeqCart(2,3,3,2,0,4,3,0);
A2: dom f = NAT by PARTFUN1:def 2;
    defpred N[Nat] means f.$1 in A;
    f.0 = [2,3] by Def10;
    then
A3: N[0] by A1;
A4: N[a] implies N[a+1]
    proof
      assume N[a];
      then consider x,y being positive Nat such that
A5:   f.a = [x,y] & R(x,y) = 0;
      set m = (f.a)`1;
      set n = (f.a)`2;
      reconsider m,n as Nat by A5;
A6:   f.(a+1) = [p1(m,n),p2(m,n)] by Def10;
A7:   m > 0 & n > 0 by Th89;
      R(p1(m,n),p2(m,n)) = 0 by A5;
      hence thesis by A6,A7;
    end;
A8: N[a] from NAT_1:sch 2(A3,A4);
A9: rng f c= A
    proof
      let y be object;
      assume y in rng f;
      then ex k being object st k in dom f & f.k = y by FUNCT_1:def 3;
      hence thesis by A8;
    end;
A10: f is one-to-one by Th92;
    defpred R[Nat,Nat] means ($1-1)^2+($1+1)^2 = $2^2+1;
    set B = { [x,y] where x,y is positive Nat : R[x,y] };
    A = B
    proof
      thus A c= B
      proof
        let a be object;
        assume a in A;
        then ex x,y being positive Nat st a = [x,y] & R(x,y) = 0;
        hence thesis;
      end;
      let a be object;
      assume a in B;
      then consider x,y being positive Nat such that
A11:  a = [x,y] and
A12:  R[x,y];
      R(x,y) = 0 by A12;
      hence thesis by A11;
    end;
    hence thesis by A2,A9,A10,CARD_1:59;
  end;
