
theorem Th5:
  for L being add-associative right_zeroed right_complementable
  associative commutative well-unital distributive almost_left_invertible non
empty doubleLoopStr, s being FinSequence of L, q being Element of L st q <> 1.
L & for i being Nat st 1 <= i & i <= len s holds s.i = q |^ (i-'1) holds Sum s
  = (1.L - q |^ (len s)) / (1.L - q)
proof
  let L be add-associative right_zeroed right_complementable associative
  commutative well-unital distributive almost_left_invertible non empty
  doubleLoopStr, s be FinSequence of L, q be Element of L;
  assume
A1: q <> 1.L & for i being Nat st 1 <= i & i <= len s holds s.i = q |^ ( i-'1);
  defpred P[Nat] means for s being FinSequence of L st len s = $1 for q being
Element of L st q <> 1.L & for i being Nat st 1 <= i & i <= len s holds s.i = q
  |^ (i-'1) holds Sum s = (1.L - q |^ (len s)) / (1.L - q);
A2: for k being Nat st P[k] holds P[k + 1]
  proof
    let k be Nat;
    assume
A3: P[k];
    now
      let s be FinSequence of L;
      set f = s| (Seg k);
      reconsider f as FinSequence by FINSEQ_1:15;
      assume
A4:   len s = k+1;
      then
A5:   1 <= len s by NAT_1:12;
      then len s in dom s by FINSEQ_3:25;
      then
A6:   s/.(len s) = s.(len s) by PARTFUN1:def 6;
A7:   k <= len s by A4,NAT_1:13;
      then
A8:   len f = k by FINSEQ_1:17;
      now
        let u be object;
        assume u in rng f;
        then consider x being object such that
A9:     x in dom f and
A10:    f.x = u by FUNCT_1:def 3;
        reconsider x9 = x as Element of NAT by A9;
        x9 <= len f by A9,FINSEQ_3:25;
        then
A11:    x9 <= len s by A4,A8,NAT_1:12;
        1 <= x9 by A9,FINSEQ_3:25;
        then
A12:    x in dom s by A11,FINSEQ_3:25;
        f.x = s.x by A9,FUNCT_1:47
          .= s/.x by A12,PARTFUN1:def 6;
        hence u in the carrier of L by A10;
      end;
      then rng f c= the carrier of L by TARSKI:def 3;
      then reconsider f as FinSequence of L by FINSEQ_1:def 4;
A13:  len s = len f + 1 by A4,A7,FINSEQ_1:17;
      let q be Element of L;
      assume that
A14:  q <> 1.L and
A15:  for i being Nat st 1 <= i & i <= len s holds s.i = q |^ (i-'1);
A16:  now
        assume 1.L - q = 0.L;
        then (1.L - q) + q = q by ALGSTR_1:def 2;
        then 1.L + (-q + q) = q by RLVECT_1:def 3;
        then 1.L + 0.L = q by RLVECT_1:5;
        hence contradiction by A14,RLVECT_1:def 4;
      end;
      len s - 1 >= 1 - 1 by A5,XREAL_1:9;
      then
A17:  len(s) -' 1 = len(s) - 1 by XREAL_0:def 2
        .= len f + 1 - 1 by A4,A7,FINSEQ_1:17;
A18:  now
        let i be Nat;
        assume that
A19:    1 <= i and
A20:    i <= len f;
A21:    i <= len s by A4,A8,A20,NAT_1:13;
        i in dom f by A19,A20,FINSEQ_3:25;
        hence f.i = s.i by FUNCT_1:47
          .= q |^ (i-'1) by A15,A19,A21;
      end;
      f = s| (dom f) by A7,FINSEQ_1:17;
      hence Sum(s) = Sum(f) + s/.(len s) by A13,A6,RLVECT_1:38
        .= (1.L - q |^ (len f)) / (1.L - q) + s/.(len s) by A3,A14,A7,A18,
FINSEQ_1:17
        .= (1.L - q |^ (len f)) / (1.L - q) + q |^ (len f) by A15,A5,A17,A6
        .= (1.L - q |^ (len f)) / (1.L - q) + (q |^ (len f) * (1.L - q)) / (
      1.L - q) by A16,Th3
        .= ((1.L - q |^ (len f)) + (q |^ (len f) * (1.L - q))) /(1.L - q) by
VECTSP_1:def 3
        .= ((1.L - q |^ (len f)) + ((q |^ (len f) * 1.L) + (q |^ (len f) * (
      -q)))) / (1.L - q) by VECTSP_1:def 2
        .= ((1.L - q |^ (len f)) + (q |^ (len f) + (q |^ (len f) * (-q)))) /
      (1.L - q)
        .= (1.L + (-q |^ (len f) + (q |^ (len f) + (q |^ (len f) * (-q)))))
      / (1.L - q) by RLVECT_1:def 3
        .= (1.L + ((-q |^ (len f) + q |^ (len f)) + (q |^ (len f) * (-q))))
      / (1.L - q) by RLVECT_1:def 3
        .= (1.L + (0.L + (q |^ (len f) * (-q)))) / (1.L - q) by RLVECT_1:5
        .= (1.L + (q |^ (len f) * (-q))) / (1.L - q) by ALGSTR_1:def 2
        .= (1.L + -((q |^ (len f) * q))) / (1.L - q) by VECTSP_1:8
        .= (1.L - q |^ (len s)) / (1.L - q) by A13,GROUP_1:def 7;
    end;
    hence thesis;
  end;
  now
    let s be FinSequence of L;
    assume len s = 0;
    then
A22: s = <*>(the carrier of L);
    let q be Element of L;
    assume that
    q <> 1.L and
    for i being Nat st 1 <= i & i <= len s holds s.i = q |^ (i-'1);
    thus (1.L - q |^ 0) / (1.L - q) = (1.L - 1_L) / (1.L - q) by BINOM:8
      .= 0.L / (1.L - q) by RLVECT_1:15
      .= 0.L
      .= Sum s by A22,RLVECT_1:43;
  end;
  then
A23: P[0];
  for k being Nat holds P[k] from NAT_1:sch 2(A23,A2);
  hence thesis by A1;
end;
