reserve V for non empty RLSStruct;
reserve x,y,y1 for set;
reserve v for VECTOR of V;
reserve a,b for Real;
reserve V for non empty addLoopStr;
reserve F for FinSequence-like PartFunc of NAT,V;
reserve f,f9,g for sequence of V;
reserve v,u for Element of V;
reserve j,k,n for Nat;
reserve V for RealLinearSpace;
reserve v for VECTOR of V;
reserve F,G,H,I for FinSequence of V;
reserve V for add-associative right_zeroed right_complementable non empty
  addLoopStr;
reserve F for FinSequence of V;
reserve v,v1,v2,u,w for Element of V;
reserve j,k for Nat;

theorem
  for V being Abelian add-associative right_zeroed non empty addLoopStr,
  F,G being FinSequence of V st rng F = rng G & F is one-to-one
  & G is one-to-one holds Sum(F) = Sum(G)
proof
  let V be Abelian add-associative right_zeroed non empty addLoopStr, F,G be
  FinSequence of V;
  defpred P[set] means for H,I being FinSequence of V st len H
= $1 & rng H = rng I & H is one-to-one & I is one-to-one holds Sum(H) = Sum (I)
  ;
A1: len F = len F;
  now
    let k;
    assume
A2: for H,I being FinSequence of V st len H = k & rng
    H = rng I & H is one-to-one & I is one-to-one holds Sum(H) = Sum(I);
    let H,I be FinSequence of V;
    assume that
A3: len H = k + 1 and
A4: rng H = rng I and
A5: H is one-to-one and
A6: I is one-to-one;
    k + 1 in Seg(k + 1) by FINSEQ_1:4;
    then
A7: k + 1 in dom H by A3,FINSEQ_1:def 3;
    then H.(k + 1) in rng I by A4,FUNCT_1:def 3;
    then consider x being object such that
A8: x in dom I and
A9: H.(k + 1) = I.x by FUNCT_1:def 3;
    reconsider v = H.(k + 1) as Element of V by A7,FUNCT_1:102;
    reconsider n = x as Element of NAT by A8;
A10: len H = len I by A4,A5,A6,FINSEQ_1:48;
    then
A11: x in Seg(k + 1) by A3,A8,FINSEQ_1:def 3;
    then
A12: n <= k + 1 by FINSEQ_1:1;
    then consider m2 being Nat such that
A13: n + m2 = k + 1 by NAT_1:10;
    defpred P[Nat,object] means $2 = I.(n + $1);
    reconsider m2 as Element of NAT by ORDINAL1:def 12;
A14: for j be Nat st j in Seg m2 ex x being object st P[j,x];
    consider q2 being FinSequence such that
A15: dom q2 = Seg m2 and
A16: for k be Nat st k in Seg m2 holds P[k,q2.k] from FINSEQ_1:sch 1 (
    A14);
A17: rng q2 c= the carrier of V
    proof
      let x be object;
      assume x in rng q2;
      then consider y being object such that
A18:  y in dom q2 and
A19:  x = q2.y by FUNCT_1:def 3;
      reconsider y as Element of NAT by A18;
      1 <= y by A15,A18,FINSEQ_1:1;
      then
A20:  1 <= n + y by NAT_1:12;
      y <= m2 by A15,A18,FINSEQ_1:1;
      then n + y <= len I by A3,A10,A13,XREAL_1:7;
      then n + y in dom I by A20,FINSEQ_3:25;
      then reconsider xx = I.(n + y) as Element of V by FUNCT_1:102;
      xx in the carrier of V;
      hence thesis by A15,A16,A18,A19;
    end;
    reconsider p = H | (Seg k) as FinSequence of V by FINSEQ_1:18;
A21: p is one-to-one by A5,FUNCT_1:52;
    Seg k = Seg(k + 1) \ {k + 1} by FINSEQ_1:10;
    then
A22: H .: (Seg k) = H .: Seg(k + 1) \ Im(H,k + 1) by A5,FUNCT_1:64;
A23: 1 <= n by A11,FINSEQ_1:1;
    then consider m1 being Nat such that
A24: 1 + m1 = n by NAT_1:10;
    reconsider q1 = I | (Seg m1) as FinSequence of V by FINSEQ_1:18;
    reconsider q2 as FinSequence of V by A17,FINSEQ_1:def 4;
    m1 <= n by A24,NAT_1:11;
    then
A25: m1 <= k + 1 by A12,XXREAL_0:2;
    then
A26: len q1 = m1 by A3,A10,FINSEQ_1:17;
A27: now
      let j be Nat;
      assume
A28:  j in dom q2;
      len(q1 ^ <* v *>) = m1 + len<* v *> by A26,FINSEQ_1:22
        .= n by A24,FINSEQ_1:39;
      hence I.(len(q1 ^ <* v *>) + j) = q2.j by A15,A16,A28;
    end;
    set q = q1 ^ q2;
A29: m1 < n by A24,XREAL_1:29;
A30: {v} misses rng q
    proof
      set y = the Element of {v} /\ rng q;
      assume not thesis;
      then
A31:  {v} /\ rng q <> {} by XBOOLE_0:def 7;
      then
A32:  y in {v} by XBOOLE_0:def 4;
A33:  now
        assume y in rng q1;
        then consider y1 being object such that
A34:    y1 in dom q1 and
A35:    y = q1.y1 by FUNCT_1:def 3;
A36:    y1 in Seg m1 by A3,A10,A25,A34,FINSEQ_1:17;
        reconsider y1 as Element of NAT by A34;
        y1 <= m1 by A36,FINSEQ_1:1;
        then
A37:    y1 <= k + 1 by A25,XXREAL_0:2;
        1 <= y1 by A36,FINSEQ_1:1;
        then y1 in Seg(k + 1) by A37,FINSEQ_1:1;
        then
A38:    y1 in dom I by A3,A10,FINSEQ_1:def 3;
        q1.y1 = I.y1 by A34,FUNCT_1:47;
        then
A39:    I.y1 = I.n by A9,A32,A35,TARSKI:def 1;
        y1 <> n by A29,A36,FINSEQ_1:1;
        hence contradiction by A6,A8,A38,A39;
      end;
A40:  y = I.n by A9,A32,TARSKI:def 1;
A41:  now
        assume y in rng q2;
        then consider y1 being object such that
A42:    y1 in dom q2 and
A43:    y = q2.y1 by FUNCT_1:def 3;
        reconsider y1 as Element of NAT by A42;
        y1 <= m2 by A15,A42,FINSEQ_1:1;
        then
A44:    n + y1 <= k + 1 by A13,XREAL_1:7;
        1 <= n + y1 by A23,NAT_1:12;
        then n + y1 in Seg(k + 1) by A44,FINSEQ_1:1;
        then
A45:    n + y1 in dom I by A3,A10,FINSEQ_1:def 3;
        I.n = I.(n + y1) by A15,A16,A40,A42,A43;
        then
A46:    n = n + y1 by A6,A8,A45;
        y1 <> 0 by A15,A42,FINSEQ_1:1;
        hence contradiction by A46;
      end;
      y in rng q by A31,XBOOLE_0:def 4;
      then y in rng q1 \/ rng q2 by FINSEQ_1:31;
      hence thesis by A33,A41,XBOOLE_0:def 3;
    end;
A47: q is one-to-one
    proof
      let y1,y2 be object;
      assume that
A48:  y1 in dom q & y2 in dom q and
A49:  q.y1 = q.y2;
      reconsider x1 = y1, x2 = y2 as Element of NAT by A48;
A50:  now
        given j1 being Nat such that
A51:    j1 in dom q2 and
A52:    x1 = len q1 + j1;
A53:    q2.j1 = I.(n + j1) by A15,A16,A51;
        j1 <= m2 by A15,A51,FINSEQ_1:1;
        then
A54:    n + j1 <= k + 1 by A13,XREAL_1:7;
        1 <= n + j1 by A23,NAT_1:12;
        then n + j1 in Seg(k + 1) by A54,FINSEQ_1:1;
        then
A55:    n + j1 in dom I by A3,A10,FINSEQ_1:def 3;
        given j2 being Nat such that
A56:    j2 in dom q2 and
A57:    x2 = len q1 + j2;
A58:    q2.j2 = I.(n + j2) by A15,A16,A56;
        j2 <= m2 by A15,A56,FINSEQ_1:1;
        then
A59:    n + j2 <= k + 1 by A13,XREAL_1:7;
        1 <= n + j2 by A23,NAT_1:12;
        then n + j2 in Seg(k + 1) by A59,FINSEQ_1:1;
        then
A60:    n + j2 in dom I by A3,A10,FINSEQ_1:def 3;
        q2.j1 = q.(m1 + j2) by A26,A49,A51,A52,A57,FINSEQ_1:def 7
          .= q2.j2 by A26,A56,FINSEQ_1:def 7;
        then n + j1 = n + j2 by A6,A53,A58,A55,A60;
        hence thesis by A52,A57;
      end;
A61:  now
        assume
A62:    x2 in dom q1;
        then q1.x2 = I.x2 by FUNCT_1:47;
        then
A63:    q.x2 = I.x2 by A62,FINSEQ_1:def 7;
A64:    x2 in Seg m1 by A3,A10,A25,A62,FINSEQ_1:17;
        then
A65:    1 <= x2 by FINSEQ_1:1;
A66:    x2 <= m1 by A64,FINSEQ_1:1;
        then x2 <= k + 1 by A25,XXREAL_0:2;
        then x2 in Seg(k + 1) by A65,FINSEQ_1:1;
        then
A67:    x2 in dom I by A3,A10,FINSEQ_1:def 3;
        given j be Nat such that
A68:    j in dom q2 and
A69:    x1 = len q1 + j;
        q2.j = I.(n + j) by A15,A16,A68;
        then
A70:    I.x2 = I.(n + j) by A49,A68,A69,A63,FINSEQ_1:def 7;
        j <= m2 by A15,A68,FINSEQ_1:1;
        then
A71:    n + j <= k + 1 by A13,XREAL_1:7;
        1 <= n + j by A23,NAT_1:12;
        then n + j in Seg(k + 1) by A71,FINSEQ_1:1;
        then
A72:    n + j in dom I by A3,A10,FINSEQ_1:def 3;
A73:    n <= n + j by NAT_1:12;
        x2 < n by A29,A66,XXREAL_0:2;
        hence thesis by A6,A70,A67,A72,A73;
      end;
A74:  now
        assume
A75:    x1 in dom q1;
        then q1.x1 = I.x1 by FUNCT_1:47;
        then
A76:    q.x1 = I.x1 by A75,FINSEQ_1:def 7;
A77:    x1 in Seg m1 by A3,A10,A25,A75,FINSEQ_1:17;
        then
A78:    1 <= x1 by FINSEQ_1:1;
A79:    x1 <= m1 by A77,FINSEQ_1:1;
        then x1 <= k + 1 by A25,XXREAL_0:2;
        then x1 in Seg(k + 1) by A78,FINSEQ_1:1;
        then
A80:    x1 in dom I by A3,A10,FINSEQ_1:def 3;
        given j be Nat such that
A81:    j in dom q2 and
A82:    x2 = len q1 + j;
        q2.j = I.(n + j) by A15,A16,A81;
        then
A83:    I.x1 = I.(n + j) by A49,A81,A82,A76,FINSEQ_1:def 7;
        j <= m2 by A15,A81,FINSEQ_1:1;
        then
A84:    n + j <= k + 1 by A13,XREAL_1:7;
        1 <= n + j by A23,NAT_1:12;
        then n + j in Seg(k + 1) by A84,FINSEQ_1:1;
        then
A85:    n + j in dom I by A3,A10,FINSEQ_1:def 3;
A86:    n <= n + j by NAT_1:12;
        x1 < n by A29,A79,XXREAL_0:2;
        hence thesis by A6,A83,A80,A85,A86;
      end;
A87:  q1 is one-to-one by A6,FUNCT_1:52;
      now
        assume
A88:    x1 in dom q1 & x2 in dom q1;
        then q1.x1 = q.x1 & q1.x2 = q.x2 by FINSEQ_1:def 7;
        hence thesis by A49,A87,A88;
      end;
      hence thesis by A48,A74,A61,A50,FINSEQ_1:25;
    end;
    k <= k + 1 by NAT_1:12;
    then
A89: len p = k by A3,FINSEQ_1:17;
A90: now
      let k be Nat;
      assume k in dom<* v *>;
      then k in Seg 1 by FINSEQ_1:38;
      then k = 1 by FINSEQ_1:2,TARSKI:def 1;
      hence H.(len p + k) = <* v *>.k by A89;
    end;
A91: now
      let j be Nat;
      assume
A92:  j in dom(q1 ^ <* v *>);
A93:  now
        assume j in Seg m1;
        then
A94:    j in dom q1 by A3,A10,A25,FINSEQ_1:17;
        then q1.j = I.j by FUNCT_1:47;
        hence I.j = (q1 ^ <* v *>).j by A94,FINSEQ_1:def 7;
      end;
A95:  now
        1 in Seg 1 & len<* v *> = 1 by FINSEQ_1:1,39;
        then 1 in dom <* v *> by FINSEQ_1:def 3;
        then
A96:    (q1 ^ <* v *>).(len q1 + 1) = <* v *>.1 by FINSEQ_1:def 7;
        assume j in {n};
        then j = n by TARSKI:def 1;
        hence (q1 ^ <* v *>).j = I.j by A9,A24,A26,A96;
      end;
      len(q1 ^ <* v *>) = m1 + len <* v *> by A26,FINSEQ_1:22
        .= m1 + 1 by FINSEQ_1:40;
      then j in Seg(m1 + 1) by A92,FINSEQ_1:def 3;
      then j in Seg m1 \/ {n} by A24,FINSEQ_1:9;
      hence I.j = (q1 ^ <* v *>).j by A93,A95,XBOOLE_0:def 3;
    end;
    len q2 = m2 by A15,FINSEQ_1:def 3;
    then len(q1 ^ <* v *>) + len q2 = len q1 + len<* v *> + m2 by FINSEQ_1:22
      .= k + 1 by A24,A13,A26,FINSEQ_1:40;
    then dom I = Seg(len(q1 ^ <* v *>) + len q2) by A3,A10,FINSEQ_1:def 3;
    then
A97: I = q1 ^ <* v *> ^ q2 by A91,A27,FINSEQ_1:def 7;
    then rng I = rng(q1 ^ <* v *>) \/ rng q2 by FINSEQ_1:31
      .= rng <* v *> \/ rng q1 \/ rng q2 by FINSEQ_1:31
      .= {v} \/ rng q1 \/ rng q2 by FINSEQ_1:39
      .= {v} \/ (rng q1 \/ rng q2) by XBOOLE_1:4
      .= {v} \/ rng q by FINSEQ_1:31;
    then
A98: rng q = rng I \ {v} by A30,XBOOLE_1:88;
A99: Seg(k + 1) = dom H by A3,FINSEQ_1:def 3;
    then rng p = H .: (Seg k) & rng H = H .: (Seg(k + 1)) by RELAT_1:113,115;
    then
A100: rng p = rng q by A4,A98,A99,A22,FINSEQ_1:4,FUNCT_1:59;
    len<* v *> = 1 & for k be Nat st k in dom p holds H.k=p.k by FINSEQ_1:39
,FUNCT_1:47;
    then H = p ^ <* v *> by A89,A99,A90,FINSEQ_1:def 7;
    then
A101: Sum(H) = Sum(p) + Sum<* v *> by Th41;
    Sum(I) = Sum(q1 ^ <* v *>) + Sum(q2) by A97,Th41
      .= (Sum(q1) + Sum<* v *>) + Sum(q2) by Th41
      .= Sum<* v *> + (Sum(q1) + Sum(q2)) by Def3
      .= Sum(q) + Sum<* v *> by Th41;
    hence Sum(H) = Sum(I) by A2,A89,A100,A21,A47,A101;
  end;
  then
A102: for k st P[k] holds P[k+1];
  now
    let H,I be FinSequence of V;
    assume that
A103: len H = 0 and
A104: rng H = rng I and
    H is one-to-one and
    I is one-to-one;
    H = {} by A103;
    then I = {} by A104;
    then
A105: len I = 0;
    Sum(H) = 0.V by A103,Lm5;
    hence Sum(H) = Sum(I) by A105,Lm5;
  end;
  then
A106: P[0];
  for k holds P[k] from NAT_1:sch 2(A106,A102);
  hence thesis by A1;
end;
