reserve a, I for set,
  S for non empty non void ManySortedSign;
reserve A, M for ManySortedSet of I,
  B, C for non-empty ManySortedSet of I;

theorem
  for A, B being non-empty MSAlgebra over S for F being
ManySortedFunction of A, B st F is_homomorphism A, B for C1 being MSCongruence
of A st C1 c= MSCng F ex H being ManySortedFunction of QuotMSAlg (A,C1), B st H
  is_homomorphism QuotMSAlg (A,C1), B & F = H ** MSNat_Hom(A,C1)
proof
  let A, B be non-empty MSAlgebra over S, F be ManySortedFunction of A, B such
  that
A1: F is_homomorphism A, B;
  MSHomQuot F is_monomorphism QuotMSAlg (A,MSCng F), B by A1,MSUALG_4:4;
  then
A2: MSHomQuot F is_homomorphism QuotMSAlg (A,MSCng F), B;
  let C1 be MSCongruence of A such that
A3: C1 c= MSCng F;
  set G = MSNat_Hom(A,C1), I = the carrier of S, sQ = the Sorts of QuotMSAlg (
  A,C1), sF = the Sorts of QuotMSAlg (A,MSCng F);
  defpred P[object,object,object] means
   ex s being Element of I, xx being Element of (
  the Sorts of A).s st $3 = s & $2 = Class(C1,xx) & $1 = Class(MSCng F,xx);
A4: for i being object st i in I
   for x being object st x in sQ.i ex y being object st y in sF.i & P[y,x,i]
  proof
    let i be object;
    assume i in I;
    then reconsider s = i as Element of I;
    let x be object;
    assume x in sQ.i;
    then consider x1 being Element of (the Sorts of A).s such that
A5: x = Class(C1,x1) by Th31;
    take y = Class(MSCng F,x1);
    y in Class ((MSCng F).s) by EQREL_1:def 3;
    hence y in sF.i by MSUALG_4:def 6;
    thus thesis by A5;
  end;
  consider C12 being ManySortedFunction of sQ, sF such that
A6: for i being object st i in I holds ex f being Function of sQ.i, sF.i st
f = C12.i & for x being object st x in sQ.i holds P[f.x,x,i]
from MSSUBFAM:sch 1(
  A4);
  reconsider H = MSHomQuot F**C12 as ManySortedFunction of QuotMSAlg (A,C1), B;
  take H;
A7: for i being Element of S for x being Element of (the Sorts of QuotMSAlg
(A,C1)).i for xx being Element of (the Sorts of A).i st x = Class(C1,xx) holds
  C12.i.x = Class(MSCng F,xx)
  proof
    let i be Element of S, x be Element of (the Sorts of QuotMSAlg (A,C1)).i,
    xx be Element of (the Sorts of A).i such that
A8: x = Class(C1,xx);
    consider f being Function of sQ.i, sF.i such that
A9: f = C12.i and
A10: for x being object st x in sQ.i holds P[f.x,x,i] by A6;
    consider s being Element of I, x1 being Element of (the Sorts of A).s such
    that
A11: i = s and
A12: x = Class(C1,x1) and
A13: f.x = Class(MSCng F,x1) by A10;
    xx in Class(C1.s,x1) by A8,A12,EQREL_1:23;
    then
A14: [xx,x1] in C1.s by EQREL_1:19;
    C1.s c= (MSCng F).s by A3;
    then xx in Class((MSCng F).s,x1) by A14,EQREL_1:19;
    hence thesis by A9,A11,A13,EQREL_1:23;
  end;
  then C12 is_epimorphism QuotMSAlg (A,C1), QuotMSAlg (A,MSCng F) by Th35;
  then C12 is_homomorphism QuotMSAlg (A,C1), QuotMSAlg (A,MSCng F);
  hence H is_homomorphism QuotMSAlg (A,C1), B by A2,MSUALG_3:10;
A15: now
    let i be object;
    assume i in the carrier of S;
    then reconsider s = i as SortSymbol of S;
A16: for x being Element of (the Sorts of A).s holds (C12.s * G.s).x = (
    MSNat_Hom(A,MSCng F)).s.x
    proof
      let x be Element of (the Sorts of A).s;
      Class(C1.s,x) in Class (C1.s) by EQREL_1:def 3;
      then
A17:  Class(C1,x) in (Class C1).s by MSUALG_4:def 6;
      thus (C12.s * G.s).x = C12.s.(G.s.x) by FUNCT_2:15
        .= C12.s.(MSNat_Hom(A,C1,s).x) by MSUALG_4:def 16
        .= C12.s.(Class(C1,x)) by MSUALG_4:def 15
        .= Class(MSCng F,x) by A7,A17
        .= MSNat_Hom(A,MSCng F,s).x by MSUALG_4:def 15
        .= (MSNat_Hom(A,MSCng F)).s.x by MSUALG_4:def 16;
    end;
    thus (C12 ** G).i = C12.s * G.s by MSUALG_3:2
      .= (MSNat_Hom(A,MSCng F)).i by A16,FUNCT_2:63;
  end;
  thus F = MSHomQuot F ** MSNat_Hom(A,MSCng F) by A1,Th30
    .= MSHomQuot F ** (C12 ** G) by A15,PBOOLE:3
    .= H ** MSNat_Hom(A,C1) by PBOOLE:140;
end;
