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

theorem Th12:
  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 F be Function of the carrier of X, the carrier of X
  st S c= dom F & (for y st y in S holds F.y = (x.|.y)*y)
  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, the carrier of X, F, the addF of X)
  .|. setopfunc(S, the carrier of X, the carrier of X, F, the addF of X)
  = setopfunc(S, the carrier of X, REAL, H, addreal)
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 F be Function of the carrier of X, the carrier of X such that
A4: S c= dom F and
A5: for y st y in S holds F.y = (x.|.y)*y;
  let H be Function of the carrier of X, REAL such that
A6: S c= dom H and
A7: for y st y in S holds H.y= (x.|.y)^2;
  consider p be FinSequence of the carrier of X such that
A8: p is one-to-one and
A9: rng p = S and
A10: setopfunc(S, the carrier of X, the carrier of X, F, the addF of X) =
  (the addF of X) "**" Func_Seq(F, p) by A1,A2,Def5;
A11: for y1, y2 st y1 in S & y2 in S & y1 <> y2
  holds (the scalar of X).[F.y1, F.y2] = 0
  proof
    let y1, y2;
    assume that
A12: y1 in S and
A13: y2 in S and
A14: y1 <> y2;
    set z1 = x.|.y1;
    set z2 = x.|.y2;
    S is OrthogonalFamily of X by Def9;
    then
A15: y1.|.y2 = 0 by A12,A13,A14,Def8;
    (the scalar of X).[F.y1, F.y2]
    = (the scalar of X).[(x.|.y1)*y1, F.y2] by A5,A12
      .= (the scalar of X).[(x.|.y1)*y1, (x.|.y2)*y2] by A5,A13
      .= (z1*y1) .|. (z2*y2) by BHSP_1:def 1
      .= z2 * (y2 .|. (z1*y1)) by BHSP_1:3
      .= z2 * (z1 * (y2 .|. y1)) by BHSP_1:3
      .= 0 by A15;
    hence thesis;
  end;
A16: for y st y in S holds H.y = (the scalar of X).[F.y, F.y]
  proof
    let y;
    assume
A17: y in S;
    then
A18: F.y = ((x.|.y) * y) by A5;
    H.y = (x.|.y)^2 by A7,A17
      .= (x.|.y) * (x.|.y) * 1
      .= (x.|.y) * (x.|.y) * (y.|.y) by A17,Def9
      .= (x.|.y) * ((x.|.y) * (y.|.y))
      .= (x.|.y) * (((x.|.y) * y).|.y) by BHSP_1:3
      .= (((x.|.y) * y).|.((x.|.y) * y)) by BHSP_1:3
      .= (the scalar of X).[F.y, F.y] by A18,BHSP_1:def 1;
    hence thesis;
  end;
  setopfunc(S, the carrier of X, the carrier of X, F, the addF of X)
  .|. setopfunc(S, the carrier of X, the carrier of X, F, the addF of X)
  = (the scalar of X).[(the addF of X) "**" Func_Seq(F, p),
  (the addF of X) "**" Func_Seq(F, p)] by A10,BHSP_1:def 1
    .= addreal "**" Func_Seq(H, p) by A3,A4,A6,A8,A9,A11,A16,Th9
    .= setopfunc(S, the carrier of X, REAL, H, addreal) by A8,A9,Def5;
  hence thesis;
end;
