reserve X for RealUnitarySpace;
reserve x, y, y1, y2 for Point of X;

theorem
  for X being RealHilbertSpace
   st the addF of X is commutative associative & the addF of X is
  having_a_unity for S be OrthonormalFamily of X for H be
  Functional of X st S c= dom H &
   (for x being Point of X st x in S holds H.x = (x.|.x)) holds S
  is summable_set implies (sum(S)).|.(sum(S)) = sum_byfunc(S, H)
proof
  let X be RealHilbertSpace such that
A1: the addF of X is commutative associative & the addF of X is having_a_unity;
  let S be OrthonormalFamily of X;
  let H be Functional of X such that
A2: S c= dom H and
A3: for x being Point of X st x in S holds H.x= (x.|.x);
A4: for Y1 be finite Subset of X st Y1 is non empty & Y1 c= S holds (setsum(
  Y1)).|.(setsum(Y1)) = setopfunc(Y1, the carrier of X, REAL, H,addreal)
  proof
    let Y1 be finite Subset of X such that
A5: Y1 is non empty and
A6: Y1 c= S;
    Y1 is finite OrthonormalFamily of X by A6,Th5;
    then
A7: Y1 is finite OrthogonalFamily of X by BHSP_5:def 9;
    for x being Point of X st x in Y1 holds H.x = (x.|.x) by A3,A6;
    hence thesis by A1,A2,A5,A6,A7,Th3,XBOOLE_1:1;
  end;
  set p1 = (sum(S)).|.(sum(S)), p2 = sum_byfunc(S, H);
  assume
A8: S is summable_set;
  then
A9: S is_summable_set_by H by A1,A2,A3,Th6;
  for e be Real st 0 < e holds |.p1 - p2.| < e
  proof
    let e be Real;
    assume 0 < e;
    then
A10: 0/2 < e/2 by XREAL_1:74;
    then consider Y02 be finite Subset of X such that
    Y02 is non empty and
A11: Y02 c= S and
A12: for Y1 be finite Subset of X st Y02 c= Y1 & Y1 c= S holds |.p2
- setopfunc(Y1, the carrier of X, REAL, H, addreal).| < e/2 by A9,BHSP_6:def 7;
    consider Y01 be finite Subset of X such that
A13: Y01 is non empty and
A14: Y01 c= S and
A15: for Y1 be finite Subset of X st Y01 c= Y1 & Y1 c= S holds |.p1
    - ((setsum Y1).|.(setsum Y1)).| < e/2 by A8,A10,Th7;
    set Y1 = Y01 \/ Y02;
A16: Y1 c= S by A14,A11,XBOOLE_1:8;
    reconsider Y011 = Y01 as non empty set by A13;
    set r = setopfunc(Y1, the carrier of X, REAL, H, addreal);
    Y1 = Y011 \/ Y02;
    then (setsum(Y1)).|.(setsum(Y1)) = r by A4,A14,A11,XBOOLE_1:8;
    then Y02 c= Y1 & |.p1 - r.| < e/2 by A15,A16,XBOOLE_1:7;
    then |.p1-r.| + |.p2-r.| < e/2 + e/2 by A12,A16,XREAL_1:8;
    then
A17: |.p1-r.| + |.r-p2.| < e by UNIFORM1:11;
    p1 - p2 = (p1 - r) + (r - p2);
    then |.p1-p2.| <= |.p1-r.| + |.r-p2.| by COMPLEX1:56;
    hence thesis by A17,XXREAL_0:2;
  end;
  hence thesis by Lm4;
end;
