reserve S for non empty non void ManySortedSign;
reserve X for non-empty ManySortedSet of S;
reserve x,y,z for set, i,j for Nat;
reserve
  A0 for (X,S)-terms non-empty MSAlgebra over S,
  A1 for all_vars_including (X,S)-terms MSAlgebra over S,
  A2 for all_vars_including inheriting_operations (X,S)-terms MSAlgebra over S,
  A for all_vars_including inheriting_operations free_in_itself
  (X,S)-terms MSAlgebra over S;

theorem Th57:
  for w being ManySortedFunction of X, (the carrier of S) --> NAT
  for s being SortSymbol of S, x being Element of X.s
  holds #(root-tree [x,s], w) = root-tree [w.s.x, s]
  proof
    let w be ManySortedFunction of X, (the carrier of S) --> NAT;
    let s be SortSymbol of S, x be Element of X.s;
    reconsider t = root-tree [x,s] as Term of S,X by MSATERM:4;
    deffunc R(set,set) = root-tree [w.$2.$1,$2];
    deffunc F(OperSymbol of S,FinSequence)
    = Sym($1,(the carrier of S)-->NAT)-tree($2);
    S-Terms X = Union the Sorts of FreeMSA X by MSATERM:13;
    then t is Element of Free(S,X) by MSAFREE3:31;
    then consider G being ManySortedSet of S-Terms X such that
A1: #(t,w) = G.t and
A2: (for s being SortSymbol of S, x being Element of X.s holds
    G.root-tree [x,s] = R(x,s)) and
    for o being OperSymbol of S, p being ArgumentSeq of Sym(o,X) holds
    G.(Sym(o,X)-tree p) = F(o,G*p) by Def15;
    thus #(root-tree [x,s], w) = root-tree [w.s.x, s] by A1,A2;
  end;
