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 Th5:
  2 <= e & (ex i st e^2 *(e *(e+2))* (n+1)^2 +1 = i^2) implies
         e - 1 + e |^ (e-'2) <= n
proof
  set a=e+1, n1=n+1,A=a^2-'1;
A1:a^2=a*a by SQUARE_1:def 1;
  assume
A2: 2 <= e;
  then
A3: e-2=e-'2 by XREAL_1:233;
  a*a>=0+1 by INT_1:7;
  then
A4: A = a*a-1 by XREAL_1:233,A1
     .= (a-1) *(a+1);
  reconsider e2=e-2 as Nat by A2,NAT_1:21;
  given i such that
A5: e^2 *(e *(e+2))*n1^2 +1 = i^2;
  (e*n1)^2 = (e*n1)*(e*n1) & e^2=e*e & n1^2=n1*n1 by SQUARE_1:def 1;
  then
A6:i^2 - A * (e*n1)^2 = 1 by A5,A4;
  [i,e*n1] is Pell's_solution of A by A6,Lm1;
  then consider j such that
A7:   i = Px(a,j) & e*n1 = Py(a,j) by A2,HILB10_1:4;
A8:  j<>0 by A7,A2,HILB10_1:3;
A9: Py(a,j),j are_congruent_mod (a-1) by A2,HILB10_1:24;
  0*n1,e*n1 are_congruent_mod e by INT_4:11,INT_1:12;
  then e divides 0-j by INT_1:def 4,A9,A7,INT_1:15;
  then e divides --j by INT_2:10;
  then e <=j by A8,INT_2:27;
  then e<j or e=j by XXREAL_0:1;
  then
A10: Py(a,e) < Py(a,j) or Py(a,e) = Py(a,j) by HILB10_1:11,A2;
A11: (2*a-1) |^(e2+1) <= Py(a,e2+1+1) by HILB10_1:17;
  (a-2)*e + e|^(e2+1) < (2*a-1) |^(e2+1)
  proof
    per cases by A2,XXREAL_0:1;
    suppose e=2;
      hence thesis;
    end;
    suppose e>2;
      then
A12:    e2+1+1>1+1;
      then
A13:    e2+1 >=1+1 by NAT_1:13;
      e2+1>1 by A12,XREAL_1:7;
      then
A14:    e2+1 is non trivial by NEWTON03:def 1;
A15:  2*a-1 = a+e;
      a>=0+1 by NAT_1:13;
      then
A16:    a|^(e2+1) >= a|^ 2 & a|^2 = a*a by A13,PREPOWER:93,NEWTON:81;
A17:    a-2 = e2+1;
      a-0>= a-1 & a-0 >= a-2 by XREAL_1:13;
      then a*a >= (a-1)*(a-2) by A17,XREAL_1:66;
      then a|^(e2+1) >= (a-1)*(a-2) by A16,XXREAL_0:2;
      then a|^(e2+1) + e|^(e2+1) >= (a-1)*(a-2) + e|^(e2+1) by XREAL_1:7;
      hence thesis by A15,A14,A2,NEWTON03:103,XXREAL_0:2;
    end;
  end;
  then (a-2)*e + e|^(e2+1) < Py(a,e2+1+1) by A11,XXREAL_0:2;
  then
A18: (a-2)*e + e|^(e2+1) < e*n1 by A7,A10,XXREAL_0:2;
  e|^(e2+1) = e* (e|^e2) by NEWTON:6;
  then (a-2)*e + e|^(e2+1) = e* ( a-2 + (e|^e2));
  then a-2 + (e|^e2) < n1 by A18,XREAL_1:64;
  hence thesis by A3,INT_1:7;
end;
