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 Th63:
  for f be FinSequence of Seg n,i st
    i in n & count_reps(f,n) = (EmptyBag n) +* (i,len f)
  holds f = len f |-> (i+1)
proof
  set E=EmptyBag n;
  let f be FinSequence of Seg n,i such that
A1: i in n & count_reps(f,n) = E +* (i,len f);
  dom E = n by PARTFUN1:def 2;
  then count_reps(f,n).i = len f by A1,FUNCT_7:31;
  then
A2: len f = card (f"{i+1}) by Def8,A1;
A3: dom f =Seg len f by FINSEQ_1:def 3;
  then card dom f = len f;
  then
A4: dom f = f"{i+1} by A2,RELAT_1:132,CARD_2:102;
  for x st x in dom f holds f.x = i+1
  proof
    let x;
    assume x in dom f;
    then f.x in {i+1} by A4,FUNCT_1:def 7;
    hence thesis by TARSKI:def 1;
  end;
  hence thesis by A3,FUNCOP_1:11;
end;
