theorem Th29:
  (ex f being FinSequence of NAT st i = Sum f & dom f = dom the_arity_of o &
  for i,t st i in dom the_arity_of o & t = p.i holds f.i = deg t)
  implies deg (o-term p) = i+1
  proof
    given f being FinSequence of NAT such that
A1: i = Sum f & dom f = dom the_arity_of o &
    for i,t st i in dom the_arity_of o & t = p.i holds f.i = deg t;
    dom f = dom p by A1,MSUALG_3:6;
    then
A2: len f = len p by FINSEQ_3:29;
    set t = o-term p;
    set I = [:the carrier' of S, {the carrier of S}:];
    set A = {<*i*>^^((p.(i+1))"I) where i: i < len p};
A4: {} nin union A
    proof
      assume {} in union A;
      then consider J such that
A1:   {} in J & J in A by TARSKI:def 4;
      consider i such that
A2:   J = <*i*>^^((p.(i+1))"I) & i < len p by A1;
      consider q being Element of (p.(i+1))"I such that
A3:   {} = <*i*>^q & q in (p.(i+1))"I by A1,A2;
      thus thesis by A3;
    end;
    reconsider J = [o,the carrier of S] as set;
    J in I by ZFMISC_1:106;
    then IFIN(J,I,{{}},{}) = {{}} by MATRIX_7:def 1;
    then t"I = {{}} \/ union A by Th80;
    then
A5: card (t"I) = card {{}}+`card union{<*i*>^^((p.(i+1))"I) where i: i < len p}
    by A4,CARD_2:35,ZFMISC_1:50
    .= 1 +` card union {<*i*>^^((p.(i+1))"I) where i: i < len p} by CARD_1:30;
    deffunc J(Nat) = <*$1*>^^((p.($1+1))"I);
A6: for i,j st i < len f & j < len f & i <> j holds J(i) misses J(j)
    proof let i,j;
B1:   len <*i*> = 1 = len <*j*> & <*i*>.1 = i & <*j*>.1 = j by FINSEQ_1:40;
      thus thesis by B1,Th2;
    end;
A7: for i st i < len f holds card J(i) = f.(i+1)
    proof let i;
      assume i < len f;
      then
A9:   1 <= i+1 <= len f by NAT_1:12,13;
      reconsider t = p.(i+1) as Element of
      (the Sorts of Free(S,X)).((the_arity_of o)/.(i+1))
      by A1,A9,FINSEQ_3:25,MSUALG_6:2;
      f.(i+1) = deg t by A1,A9,FINSEQ_3:25;
      hence thesis by Th1;
    end;
    card union {J(i) where i: i < len f} = Sum f from CardUnion(A6,A7);
    then card (t"I) = 1+` Sum f by A2,A5;
    hence deg t = i+1 by A1;
  end;
