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;
reserve X0 for non-empty countable ManySortedSet of S;
reserve A0 for all_vars_including inheriting_operations free_in_itself
  (X0,S)-terms MSAlgebra over S;

theorem
  for X0,Y0 being non-empty countable ManySortedSet of S
  for A being all_vars_including inheriting_operations
  (X0,S)-terms MSAlgebra over S
  for h being ManySortedFunction of Free(S,Y0), A st
  h is_homomorphism Free(S,Y0), A
  ex g being ManySortedFunction of Free(S,Y0),Free(S,X0) st
  g is_homomorphism Free(S,Y0),Free(S,X0) & h = (canonical_homomorphism A)**g &
  for G being GeneratorSet of Free(S,Y0) st G = FreeGen Y0
  holds g||G = h||G
  proof
    let X0,Y be non-empty countable ManySortedSet of S;
    let A be all_vars_including inheriting_operations
    (X0,S)-terms MSAlgebra over S;
    let h be ManySortedFunction of Free(S,Y), A such that
A1: h is_homomorphism Free(S,Y), A;
    set ww = canonical_homomorphism A;
    reconsider F = FreeGen Y as GeneratorSet of Free(S,Y) by Th45;
    reconsider H = FreeGen X0 as GeneratorSet of Free(S,X0) by Th45;
    reconsider G = FreeGen X0 as GeneratorSet of A by Th45;
    now
      let s be SortSymbol of S, i be Element of X0.s;
      root-tree [i,s] in FreeGen(s,X0) by MSAFREE:def 15;
      then A2: root-tree [i,s] in H.s by MSAFREE:def 16;
      G c= the Sorts of A by PBOOLE:def 18;
      then H.s c= (the Sorts of A).s;
      hence ww.s.root-tree [i,s] = root-tree [i, s] by A2,Th47;
    end; then
A3: ww is_homomorphism Free(S,X0), A &
    for s being SortSymbol of S, i being Element of X0.s holds
    ww.s.root-tree [i,s] = root-tree [i, s] by Def10;
    the Sorts of A is MSSubset of Free(S,X0) by Def6;
    then reconsider hG = h||F as ManySortedFunction of
    F qua ManySortedSet of S, the Sorts of Free(S,X0) by Th22;
    FreeGen Y is free & FreeMSA Y = Free(S,Y) by MSAFREE3:31;
    then consider g being ManySortedFunction of Free(S,Y),Free(S,X0) such that
A4: g is_homomorphism Free(S,Y),Free(S,X0) & g||F = hG;
    take g;
    thus g is_homomorphism Free(S,Y),Free(S,X0) by A4;
A5: ww**g is_homomorphism Free(S,Y),A by A3,A4,MSUALG_3:10;
    now
      let x be object; assume x in the carrier of S;
      then reconsider s = x as SortSymbol of S;
A6:   dom ((h||F).s) = F.s & dom (((ww**g)||F).s) = F.s by FUNCT_2:def 1;
      now let y be object; assume
A7:     y in F.s;
A8:     g.s.y = ((g.s)|(F.s)).y by A7,FUNCT_1:49
        .= (h||F).s.y by A4,MSAFREE:def 1;
        then
A9:     g.s.y in (the Sorts of A).s by A7,FUNCT_2:5;
A10:     F.s c= (the Sorts of Free(S,Y)).s by PBOOLE:def 2,def 18;
A11:     dom (ww**g) = (the carrier of S)/\the carrier of S
        by PARTFUN1:def 2;
        thus (h||F).x .y = ww.s.(g.s.y) by A8,A9,Th47
        .= ((ww.s)*(g.s)).y by A7,A10,FUNCT_2:15
        .= ((ww**g).s).y by A11,PBOOLE:def 19
        .= (((ww**g).s)|(F.s)).y by A7,FUNCT_1:49
        .= ((ww**g)||F).x .y by MSAFREE:def 1;
      end;
      hence (h||F).x = ((ww**g)||F).x by A6;
    end;
    hence h = ww**g by A1,A5,EXTENS_1:19,PBOOLE:3;
    thus thesis by A4;
  end;
