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 Th61:
  for f be FinSequence of Seg n
    holds degree count_reps(f,n) = len f
proof
  defpred P[Nat] means for f be FinSequence of Seg n st len f= $1
    holds degree count_reps(f,n) = len f;
A1: P[0]
  proof
    let f be  FinSequence of Seg n such that
A2: len f= 0;
    f={} by A2;
    then count_reps(f,n) = EmptyBag n by Th54;
    hence thesis by UPROOTS:11,A2;
  end;
A3:P[i] implies P[i+1]
  proof
    assume
A4: P[i];
    let f be FinSequence of Seg n such that
A5: len f= i+1;
    1<= i+1 by NAT_1:11;
    then i+1 in dom f by A5,FINSEQ_3:25;
    then
A6: f.(i+1) in rng f c= Seg n
    by FUNCT_1:def 3,FINSEQ_1:def 4;
    then f.(i+1)>=1 by FINSEQ_1:1;
    then reconsider fi1 = f.(i+1)-1 as Nat;
    set fi=f|i,F = <*fi1+1*>;
A7: len fi = i by NAT_1:11,A5,FINSEQ_1:59;
    then
A8: degree count_reps(fi,n) = len fi by A4;
    fi1+1 <= n by A6,FINSEQ_1:1;
    then fi1 <n by NAT_1:13;
    then
A9: fi1 in Segm n by NAT_1:44;
    reconsider N=n as non empty set by A5;
    reconsider a=fi1 as Element of N by A9;
    reconsider A={fi1} as Subset of N by A9,ZFMISC_1:31;
    (EmptyBag n) +*(fi1,1) = ({a},1)-bag by Th12;
    then
A10: degree ((EmptyBag n) +*(fi1,1)) = card {a} =1
    by UPROOTS:13,CARD_1:30;
    f = fi^F by FINSEQ_3:55,A5;
    then count_reps(f,n) = count_reps(fi,n) + (EmptyBag n) +*(fi1,1) by Th55;
    hence thesis by A10,A8,A7,A5,UPROOTS:15;
  end;
  P[i] from NAT_1:sch 2(A1,A3);
  hence thesis;
end;
