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

theorem Th9:
  for S be finite non empty Subset of X
  for F be Function of the carrier of X, the carrier of X
  st S c= dom F & (for y1,y2 st y1 in S & y2 in S & y1 <> y2
  holds (the scalar of X).[F.y1,F.y2] = 0)
  for H be Function of the carrier of X, REAL
  st S c= dom H & (for y st y in S holds H.y= (the scalar of X).[F.y,F.y])
  for p be FinSequence of the carrier of X
  st p is one-to-one & rng p = S holds
  (the scalar of X).[(the addF of X) "**" Func_Seq(F,p),
  (the addF of X) "**" Func_Seq(F,p)] = addreal "**" Func_Seq(H,p)
proof
  let S be finite non empty Subset of X;
  let F be Function of the carrier of X, the carrier of X such that
A1: S c= dom F and
A2: for y1, y2 st y1 in S & y2 in S & y1 <> y2 holds (the scalar of X).
  [F.y1, F.y2]=0;
  let H be Function of the carrier of X, REAL such that
A3: S c= dom H and
A4: for y st y in S holds H.y = (the scalar of X).[F.y, F.y];
  let p be FinSequence of the carrier of X such that
A5: p is one-to-one and
A6: rng p = S;
  set fp = Func_Seq(F, p);
  set hp = Func_Seq(H, p);
  now
    let z be object;
    z in dom p implies p.z in rng p by FUNCT_1:3;
    hence z in dom fp iff z in dom p by A1,A6,FUNCT_1:11;
  end;
  then
A7: dom fp = dom p by TARSKI:2;
  then
A8: Seg len p = dom fp by FINSEQ_1:def 3
    .= Seg len fp by FINSEQ_1:def 3;
A9: len p = card S by A5,A6,FINSEQ_4:62;
  0 < card S;
  then 0+1 <= card S by INT_1:7;
  then
A10: 1 <= len fp by A8,A9,FINSEQ_1:6;
A11: for i, j st i in dom fp & j in dom fp & i <> j
  holds (the scalar of X).[fp.i, fp.j] = 0
  proof
    let i, j;
    assume that
A12: i in dom fp and
A13: j in dom fp and
A14: i <> j;
A15: p.i in S by A6,A7,A12,FUNCT_1:3;
A16: p.j in S by A6,A7,A13,FUNCT_1:3;
A17: fp.i = F.(p.i) by A12,FUNCT_1:12;
A18: fp.j = F.(p.j) by A13,FUNCT_1:12;
    p.i <> p.j by A5,A7,A12,A13,A14,FUNCT_1:def 4;
    hence thesis by A2,A15,A16,A17,A18;
  end;
  now
    let z be object;
    z in dom p implies p.z in rng p by FUNCT_1:3;
    hence z in dom hp iff z in dom p by A3,A6,FUNCT_1:11;
  end;
  then
A19: dom hp = dom p by TARSKI:2;
A20: for i st i in dom hp holds hp.i = (the scalar of X).[fp.i, fp.i]
  proof
    let i such that
A21: i in dom hp;
A22: p.i in S by A6,A19,A21,FUNCT_1:3;
    hp.i = H.(p.i) by A19,A21,FUNCT_1:13
      .= (the scalar of X).[F.(p.i), F.(p.i)] by A4,A22
      .= (the scalar of X).[(F*p).i, F.(p.i)] by A19,A21,FUNCT_1:13
      .= (the scalar of X).[fp.i, fp.i] by A19,A21,FUNCT_1:13;
    hence thesis;
  end;
  (the scalar of X).[(the addF of X) "**" Func_Seq(F, p),
  (the addF of X) "**" Func_Seq(F, p)]
  = ((the addF of X) "**" fp).|.((the addF of X) "**" fp) by BHSP_1:def 1
    .= addreal "**" Func_Seq(H,p) by A7,A10,A11,A19,A20,Th7;
  hence thesis;
end;
