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 Th62:
  for w being ManySortedFunction of (the carrier of S)-->NAT, X
  ex h being ManySortedFunction of TermAlg S, A st
  h is_homomorphism TermAlg S, A &
  for s being SortSymbol of S, i being Nat holds
  h.s.root-tree [i,s] = root-tree [w.s.i, s]
  proof
    set Y = (the carrier of S)-->NAT;
    let w be ManySortedFunction of Y, X;
    deffunc F(set,Function) = root-tree [w.$1.($2.{})`1, $1];
    consider ww being ManySortedFunction of the carrier of S such that
A1: for x st x in the carrier of S holds dom(ww.x) = (FreeGen Y).x &
    for y being Element of (FreeGen Y).x holds ww.x .y = F(x,y) from Sch1;
A2: ww is ManySortedFunction of FreeGen Y, FreeGen X
    proof
      let x be object; assume x in the carrier of S;
      then reconsider s = x as SortSymbol of S;
A3:   dom(ww.s) = (FreeGen Y).s by A1;
A4:   (FreeGen X).s = FreeGen(s,X) & (FreeGen Y).s = FreeGen(s,Y)
      by MSAFREE:def 16;
      rng(ww.s) c= (FreeGen X).s
      proof
        let y be object; assume y in rng(ww.s);
        then consider z being object such that
A5:     z in dom(ww.s) & y = ww.s.z by FUNCT_1:def 3;
        reconsider z as Element of (FreeGen Y).s by A1,A5;
        consider v being set such that
A6:     v in Y.s & z = root-tree [v,s] by A4,MSAFREE:def 15;
A7:     y = F(s,z) by A1,A5;
        z.{} = [v,s] by A6,TREES_4:3;
        then (z.{})`1 = v;
        then w.s.(z.{})`1 in X.s by A6,FUNCT_2:5;
        hence thesis by A4,A7,MSAFREE:def 15;
      end;
      hence thesis by A3,FUNCT_2:2;
    end;
    reconsider G = FreeGen Y as GeneratorSet of TermAlg S;
    FreeGen X is MSSubset of A by Def7;
    then reconsider ww as ManySortedFunction of G, the Sorts of A by A2,Th22;
    consider h being ManySortedFunction of TermAlg S, A such that
A8: h is_homomorphism TermAlg S, A & ww = h||G by MSAFREE:def 5;
    take h; thus h is_homomorphism TermAlg S, A by A8;
    let s be SortSymbol of S, i be Nat;
A9: ww.s = (h.s)|(G.s) by A8,MSAFREE:def 1;
    i in NAT & NAT = Y.s by ORDINAL1:def 12;
    then root-tree [i,s] in FreeGen(s,Y) & FreeGen(s,Y) = G.s
    by MSAFREE:def 15,def 16;
    then reconsider z = root-tree [i,s] as Element of (FreeGen Y).s;
    thus h.s.root-tree [i,s] = ww.s.z by A9,FUNCT_1:49
    .= F(s,z) by A1 .= root-tree [w.s.[i,s]`1, s] by TREES_4:3
    .= root-tree [w.s.i, s];
  end;
