reserve i,j,k,n,m for Nat,
        X for set,
        b,s for bag of X,
        x for object;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
          right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
             right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;

theorem Th55:
  for f be FinSequence holds
    count_reps(f^<*i+1*>,n) = count_reps(f,n) + (EmptyBag n) +*(i,1)
proof
  let f be FinSequence;
  set s1=count_reps(f^<*i+1*>,n), s = count_reps(f,n), E = EmptyBag n;
A1:dom s1 = n = dom (s+E+*(i,1)) & n = dom E by PARTFUN1:def 2;
  for x be object st x in dom s1 holds s1.x=(s+E+*(i,1)).x
  proof
    let x be object such that
A2: x in dom s1;
    x in Segm n by A2;
    then reconsider a=x as Nat;
A3: card ((f^<*i+1*>)"{a+1}) = card (f"{a+1}) + card (<*i+1*>"{a+1})
    by FINSEQ_3:57;
A4: rng <*i+1*> = {i+1} by FINSEQ_1:38;
    per cases;
    suppose
A5:   a<>i;
      then a+1 <>i+1;
      then
A6:   <*i+1*>"{a+1} = {} by A4,RELAT_1:138,ZFMISC_1:11;
A7:   (E+*(i,1)).a = E.a = 0 by A5,FUNCT_7:32;
      thus s1.x = card (f"{a+1}) +0 by A6,A2,Def8,A3
      .= s.a +0 by A2,Def8
      .= (s+E+*(i,1)).x by A7,A2,A1,VALUED_1:def 1;
    end;
    suppose
A8:   a=i;
      then
A9:   <*i+1*>"{a+1} = dom <*i+1*> = Seg 1 ={1}
      by A4,RELAT_1:134,FINSEQ_1:38,2;
A10: (E+*(i,1)).a = 1 by A8,A1,A2,FUNCT_7:31;
      thus s1.x = card (f"{a+1}) +1 by A9,A2,Def8,A3
      .= s.a +1 by A2,Def8
      .= (s+E+*(i,1)).x by A10,A2,A1,VALUED_1:def 1;
    end;
  end;
  hence thesis by A1;
end;
