reserve I for set;
reserve S for non empty non void ManySortedSign,
  U0, U1 for non-empty MSAlgebra over S;

theorem Th24:
  for W being strict free non-empty MSAlgebra over S for F being
  ManySortedFunction of U0, U1 st F is_epimorphism U0, U1 for G being
  ManySortedFunction of W, U1 st G is_homomorphism W, U1 holds ex H being
  ManySortedFunction of W, U0 st H is_homomorphism W, U0 & G = F ** H
proof
  let W be strict free non-empty MSAlgebra over S, F be ManySortedFunction of
  U0, U1 such that
A1: F is_epimorphism U0, U1;
  set sU0 = the Sorts of U0, sU1 = the Sorts of U1, I = the carrier of S;
  let G be ManySortedFunction of W, U1 such that
A2: G is_homomorphism W, U1;
  consider Gen be GeneratorSet of W such that
A3: Gen is free by MSAFREE:def 6;
  defpred P[object,object,object] means
ex f be Function of sU0.$3, sU1.$3 st ex g be
  Function of Gen.$3, sU1.$3 st f = F.$3 & g = (G || Gen).$3 & $1 in f"{g.$2};
A4: for i being object st i in I
for x be object st x in Gen.i ex y be object st y in
  sU0.i & P[y,x,i]
  proof
    let i be object such that
A5: i in I;
    reconsider g = (G || Gen).i as Function of Gen.i, sU1.i by A5,PBOOLE:def 15
;
    reconsider f = F.i as Function of sU0.i, sU1.i by A5,PBOOLE:def 15;
    let x be object;
    assume x in Gen.i;
    then
A6: g.x in sU1.i by A5,FUNCT_2:5;
    F is "onto" by A1;
    then rng (F.i) = sU1.i by A5;
    then f"{g.x} <> {} by A6,FUNCT_2:41;
    then consider y be object such that
A7: y in f"{g.x} by XBOOLE_0:def 1;
    take y;
    thus y in sU0.i by A7;
    thus thesis by A7;
  end;
  consider H be ManySortedFunction of Gen, sU0 such that
A8: for i be object st i in I
  ex h be Function of Gen.i, sU0.i st h = H.i
  & for x be object st x in Gen.i holds P[h.x,x,i] from MSSUBFAM:sch 1(A4);
  consider H1 be ManySortedFunction of W, U0 such that
A9: H1 is_homomorphism W, U0 and
A10: H1 || Gen = H by A3;
  now
    let i be object;
    assume
A11: i in I;
    then reconsider f9 = F.i as Function of sU0.i, sU1.i by PBOOLE:def 15;
    reconsider g9 = (G || Gen).i as Function of Gen.i, sU1.i by A11,
PBOOLE:def 15;
    consider h be Function of Gen.i, sU0.i such that
A12: h = H.i and
A13: for x be object st x in Gen.i holds ex f be Function of sU0.i, sU1.i
st ex g be Function of Gen.i, sU1.i st f = F.i & g = (G || Gen).i & h.x in f"{g
    .x} by A8,A11;
A14: now
      let x be object;
      assume
A15:  x in Gen.i;
      then consider
      f be Function of sU0.i, sU1.i, g be Function of Gen.i, sU1.i
      such that
A16:  f = F.i & g = (G || Gen).i and
A17:  h.x in f"{g.x} by A13;
      f.(h.x) in {g.x} by A11,A17,FUNCT_2:38;
      then f.(h.x) = g.x by TARSKI:def 1;
      hence (f9*h).x = g9.x by A15,A16,A17,FUNCT_2:15;
    end;
    Gen.i = dom g9 & Gen.i = dom (f9*h) by A11,FUNCT_2:def 1;
    then g9 = f9 * h by A14,FUNCT_1:2;
    hence (G || Gen).i = (F ** H).i by A11,A12,MSUALG_3:2;
  end;
  then G || Gen = F ** (H1 || Gen) by A10;
  then
A18: G || Gen = (F ** H1) || Gen by EXTENS_1:4;
  take H1;
  thus H1 is_homomorphism W, U0 by A9;
  F is_homomorphism U0, U1 by A1;
  then F ** H1 is_homomorphism W, U1 by A9,MSUALG_3:10;
  hence thesis by A2,A18,EXTENS_1:19;
end;
