 reserve i,j, k,v, w for Nat;
 reserve j1,j2, m, n, s, t, x, y for Integer;
 reserve p for odd Prime;
 reserve a for Real;
 reserve b for Integer;

theorem Them7:
  for p be Prime, n be Nat holds
    ex x1,x2,x3,x4 be Nat st p|^n = x1^2 + x2^2 + x3^2 + x4^2
  proof
    let p be Prime, n be Nat;
    defpred P[Nat] means ex x1,x2,x3,x4 be Nat
      st p|^$1 = x1^2 + x2^2 + x3^2 + x4^2;
A1: for n be Nat st P[n] holds P[n+1]
    proof
      let n be Nat; assume P[n]; then
      consider x1,x2,x3,x4 be Nat such that
A3:   p|^n = x1^2 + x2^2 + x3^2 + x4^2;
      consider y1,y2,y3,y4 be Nat such that
A4:   p = y1^2 + y2^2 + y3^2 + y4^2 by Them5;
      set z1 = x1*y1 + x2*y2 +x3*y3 + x4*y4,
          z2 = -x1*y2 + x2*y1 - x3*y4 + x4*y3,
          z3 = x1*y3 - x2*y4 - x3*y1 + x4*y2,
          z4 = x1*y4 + x2*y3 - x3*y2 - x4*y1;
      reconsider n1 = |. z1 .|, n2 = |. z2 .|, n3 = |. z3 .|, n4 = |. z4 .|
        as natural Number;
      reconsider n1,n2,n3,n4 as Nat by TARSKI:1;
A6:   n1^2 = z1^2 & n2^2 = z2^2 & n3^2 = z3^2 & n4^2 = z4^2 by COMPLEX1:75;
      p|^(n + 1) = p|^n * p by NEWTON:6
         .= z1^2 + z2^2 + z3^2 + z4^2 by A3,A4
         .= n1^2 + n2^2 + n3^2 + n4^2 by A6;
      hence thesis;
    end;
A8: P[0]
    proof
      consider x1,x2,x3,x4 be Nat such that
A9:   x1 = 1 & x2 = 0 & x3 = 0 & x4 = 0;
      p|^0 = x1^2 + x2^2 + x3^2 + x4^2 by A9,NEWTON:4;
      hence thesis;
    end;
    for n be Nat holds P[n] from NAT_1:sch 2(A8,A1);
    hence thesis;
  end;
