reserve A for non empty set,
  S for non void non empty ManySortedSign;
reserve x for set;
reserve o for OperSymbol of S;

theorem Th5:
  for U1,U2,U3 be feasible MSAlgebra over S,
      F be ManySortedFunction of U1,U2,
      G be ManySortedFunction of U2,U3 st
  the Sorts of U1 is_transformable_to the Sorts of U2 &
  the Sorts of U2 is_transformable_to the Sorts of U3 &
  F is_homomorphism U1,U2 & G is_homomorphism U2,U3
  ex GF be ManySortedFunction of U1,U3 st
    GF = G ** F & GF is_homomorphism U1,U3
proof
  let U1,U2,U3 be feasible MSAlgebra over S, F be ManySortedFunction of U1,U2,
  G be ManySortedFunction of U2,U3;
  assume that
A1: the Sorts of U1 is_transformable_to the Sorts of U2 and
A2: the Sorts of U2 is_transformable_to the Sorts of U3 and
A3: F is_homomorphism U1,U2 and
A4: G is_homomorphism U2,U3;
  reconsider GF = G ** F as ManySortedFunction of U1,U3 by A1,ALTCAT_2:4;
  take GF;
  thus GF = G ** F;
  thus GF is_homomorphism U1,U3
  proof
    let o be OperSymbol of S such that
A5: Args(o,U1) <> {};
    let x be Element of Args(o,U1);
A6: ex gf be ManySortedFunction of U1,U3 st gf = G ** F & gf #x = G#(F#x)
    by A1,A2,A5,Th4;
    set r = the_result_sort_of o;
    (F.r).(Den(o,U1).x) = Den(o,U2).(F#x) & Args (o,U2) <> {} by A1,A3,A5,Th3;
    then
A7: (G.r).((F.r).(Den(o,U1).x)) = Den(o,U3).(G#(F#x)) by A4;
A8: the Sorts of U1 is_transformable_to the Sorts of U3 by A1,A2,AUTALG_1:10;
A9: dom (GF.r) = (the Sorts of U1).r
    proof
      per cases;
      suppose
        (the Sorts of U1).r <> {};
        then (the Sorts of U3).r <> {} by A8,PZFMISC1:def 3;
        hence thesis by FUNCT_2:def 1;
      end;
      suppose
        (the Sorts of U1).r = {};
        hence thesis;
      end;
    end;
    o in the carrier' of S;
    then
A10: o in dom (the ResultSort of S) by FUNCT_2:def 1;
    rng (the ResultSort of S) c= the carrier of S;
    then rng (the ResultSort of S) c= dom (the Sorts of U1) by PARTFUN1:def 2;
    then Result(o,U1) = ((the Sorts of U1)*(the ResultSort of S)).o & dom ((
    the Sorts of U1)*(the ResultSort of S)) = dom (the ResultSort of S) by
MSUALG_1:def 5,RELAT_1:27;
    then
A11: Result(o,U1) = (the Sorts of U1).((the ResultSort of S).o) by A10,
FUNCT_1:12
      .= (the Sorts of U1).r by MSUALG_1:def 2;
    then GF.r = (G.r)*(F.r) & (the Sorts of U1).r <> {} by A5,MSUALG_3:2
,MSUALG_6:def 1;
    hence thesis by A5,A7,A9,A11,A6,FUNCT_1:12,FUNCT_2:5;
  end;
end;
