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 Th51:
  for a,b,c being Prime st n|^2-1 = a*b*c holds n-1 is prime or n+1 is prime
  proof
    let a,b,c be Prime such that
A1: n|^2-1 = a*b*c;
A2: n|^2 = n^2 by WSIERP_1:1;
    then
A3: n|^2-1 = (n-1)*(n+1);
A4: now
      assume n < 1;
      then n = 0 by NAT_1:14;
      hence contradiction by A1;
    end;
    c divides (n-1)*(n+1) by A1,A2;
    then per cases by INT_5:7;
    suppose c divides n-1;
      then c*(n+1) divides (n-1)*(n+1) by NAT_3:1;
      then n+1 = 0+1 or n+1 = a or n+1 = b or n+1 = a*b
      by A1,A2,GROUP_22:1,GR_CY_3:1;
      then per cases by A1;
      suppose n+1 = a or n+1 = b;
        hence thesis;
      end;
      suppose n+1 = a*b;
        hence thesis by A1,A3,XCMPLX_1:5;
      end;
    end;
    suppose c divides n+1;
      then c*(n-1) divides (n+1)*(n-1) by NAT_3:1;
      then per cases by A1,A2,A4,GROUP_22:1,GR_CY_3:1;
      suppose n-1 = 1;
        hence thesis by XPRIMES1:3;
      end;
      suppose n-1 = a or n-1 = b;
        hence thesis;
      end;
      suppose n-1 = a*b;
        hence thesis by A1,A3,XCMPLX_1:5;
      end;
    end;
  end;
