reserve X for RealUnitarySpace;
reserve x, y, y1, y2 for Point of X;
reserve xd for set;
reserve i, j, n for Nat;

theorem
  for X st the addF of X is commutative associative &
  the addF of X is having_a_unity for x
  for S be finite OrthonormalFamily of X st S is non empty
  for H be Function of the carrier of X, REAL
  st S c= dom H & (for y st y in S holds H.y = (x.|.y)^2) holds
  setopfunc(S, the carrier of X, REAL, H, addreal) <= ||.x.||^2
proof
  let X such that
A1: the addF of X is commutative associative and
A2: the addF of X is having_a_unity;
  let x;
  let S be finite OrthonormalFamily of X such that
A3: S is non empty;
  let H be Function of the carrier of X, REAL such that
A4: S c= dom H and
A5: for y st y in S holds H.y= (x.|.y)^2;
  now
    deffunc F(object) = (the Mult of X) .[(the scalar of X).[x,$1],$1];
A6: for y be object st y in the carrier of X holds F(y) in the carrier of X
    proof
      let y be object such that
A7:   y in the carrier of X;
      reconsider y1 = y as Point of X by A7;
      set x1 = x;
      (the scalar of X).[x,y] = x1.|.y1 by BHSP_1:def 1;
      then reconsider a = (the scalar of X).[x,y] as Real;
      reconsider y2 = y as VECTOR of X by A7;
      (the Mult of X).((the scalar of X).[x,y],y) = a * y2;
      hence thesis;
    end;
    ex F0 being Function of the carrier of X,the carrier of X
    st for y be object st y in the carrier of X holds F0.y=F(y) from
    FUNCT_2:sch 2(A6);
    then consider F0 be Function of the carrier of X, the carrier of X such
    that
A8: for y be object st y in the carrier of X holds
    F0.y = (the Mult of X) .[(the scalar of X).[x,y],y];
A9: dom F0 = the carrier of X by FUNCT_2:def 1;
    now
      let y such that y in S;
      thus F0.y = (the Mult of X).[(the scalar of X).[x,y],y] by A8
        .= (x.|.y)*y by BHSP_1:def 1;
    end;
    then consider F be Function of the carrier of X, the carrier of X
    such that
A10: S c= dom F and
A11: for y st y in S holds F.y = (x.|.y)*y by A9;
    set z=setopfunc(S,the carrier of X,the carrier of X,F,the addF of X);
    z.|.x = setopfunc(S, the carrier of X, REAL, H, addreal)
    by A1,A2,A3,A4,A5,A10,A11,Th11;
    then x.|.z = z.|.z by A1,A2,A3,A4,A5,A10,A11,Th12;
    then (x - z).|.(x - z) = ((x.|.x - z.|.z) - z.|.z ) + z.|.z by BHSP_1:13
      .= x.|.x - setopfunc(S, the carrier of X, REAL, H, addreal)
    by A1,A2,A3,A4,A5,A10,A11,Th12;
    hence 0 <= x.|.x - setopfunc(S, the carrier of X, REAL, H, addreal)
    by BHSP_1:def 2;
  end;
  then
A12: 0 + setopfunc(S, the carrier of X, REAL, H, addreal) <= x.|.x
  by XREAL_1:19;
  0 <= x.|.x by BHSP_1:def 2;
  then setopfunc(S, the carrier of X, REAL, H, addreal) <= (sqrt (x.|.x))^2
  by A12,SQUARE_1:def 2;
  hence thesis by BHSP_1:def 4;
end;
