reserve S for locally_directed OrderSortedSign;
reserve o for Element of the carrier' of S;

theorem
  for U1,U2 be non-empty OSAlgebra of S, F be ManySortedFunction of U1,
U2, R be OSCongruence of U1 st F is_homomorphism U1,U2 & F is order-sorted & R
c= OSCng F holds OSHomQuot(F,R) is_homomorphism QuotOSAlg (U1,R),U2 & OSHomQuot
  (F,R) is order-sorted
proof
  let U1,U2 be non-empty OSAlgebra of S, F be ManySortedFunction of U1,U2, R
  be OSCongruence of U1;
  set mc = R, qa = QuotOSAlg (U1,mc), qh = OSHomQuot(F,R), S1 = the Sorts of
  U1;
  assume that
A1: F is_homomorphism U1,U2 and
A2: F is order-sorted and
A3: R c= OSCng F;
  for o be Element of the carrier' of S st Args (o,qa) <> {} for x be
Element of Args(o,qa) holds (qh.(the_result_sort_of o)).(Den(o,qa).x) = Den(o,
  U2).(qh#x)
  proof
    let o be Element of the carrier' of S such that
    Args (o,qa) <> {};
    let x be Element of Args(o,qa);
    reconsider o1 = o as OperSymbol of S;
    set ro = the_result_sort_of o, ar = the_arity_of o;
A4: dom x = dom ar by MSUALG_3:6;
    Args(o,qa) = ((OSClass mc)# * (the Arity of S)).o by MSUALG_1:def 4;
    then consider a be Element of Args(o,U1) such that
A5: x = mc #_os a by Th14;
A6: dom a = dom ar by MSUALG_3:6;
A7: now
      let y be object;
      assume
A8:   y in dom ar;
      then reconsider n = y as Nat;
      ar.n in rng ar by A8,FUNCT_1:def 3;
      then reconsider s = ar.n as SortSymbol of S;
A9:   ar/.n = ar.n by A8,PARTFUN1:def 6;
      then consider an being Element of S1.s such that
A10:  an = a.n and
A11:  x.n = OSClass(mc,an) by A5,A8,Def13;
      (qh # x).n = (qh.s).(x.n) by A4,A8,A9,MSUALG_3:def 6
        .= OSHomQuot(F,R,s).OSClass(mc,an) by A11,Def28
        .= (F.s).an by A1,A2,A3,Def27
        .= (F # a).n by A6,A8,A9,A10,MSUALG_3:def 6;
      hence (qh # x).y = (F # a).y;
    end;
    o in the carrier' of S;
    then o in dom (S1 * the ResultSort of S) by PARTFUN1:def 2;
    then
A12: ((the Sorts of U1) * the ResultSort of S).o = (the Sorts of U1).((the
    ResultSort of S).o) by FUNCT_1:12
      .= (the Sorts of U1).ro by MSUALG_1:def 2;
    then rng Den(o,U1) c= Result(o,U1) & Result(o,U1) = S1.ro by MSUALG_1:def 5
;
    then rng Den(o,U1) c= dom OSQuotRes(mc,o) by A12,FUNCT_2:def 1;
    then
A13: dom Den(o,U1) = Args(o,U1) & dom ((OSQuotRes(mc,o)) * Den(o,U1)) =
    dom Den(o,U1) by FUNCT_2:def 1,RELAT_1:27;
    ar = (the Arity of S).o by MSUALG_1:def 1;
    then
A14: product((OSClass mc) * ar) = ((OSClass mc)# * the Arity of S).o by
MSAFREE:1;
    reconsider da = (Den(o,U1)).a as Element of S1.ro by A12,MSUALG_1:def 5;
A15: qh.ro = OSHomQuot(F,R,ro) by Def28;
    Den(o,qa) = (OSQuotCharact mc).o by MSUALG_1:def 6
      .= OSQuotCharact(mc,o1) by Def19;
    then Den(o,qa).x = (OSQuotRes(mc,o) * Den(o,U1)).a by A5,A14,Def18
      .= (OSQuotRes(mc,o)) . da by A13,FUNCT_1:12
      .= OSClass (R,da) by Def14;
    then
A16: (qh.ro).(Den(o,qa).x) = (F.ro).((Den(o,U1)).a) by A1,A2,A3,A15,Def27
      .= Den(o,U2).(F#a) by A1;
    dom (qh # x) = dom ar & dom (F # a) = dom ar by MSUALG_3:6;
    hence thesis by A7,A16,FUNCT_1:2;
  end;
  hence qh is_homomorphism qa,U2;
  thus OSHomQuot(F,R) is order-sorted
  proof
    reconsider S1O = S1 as OrderSortedSet of S by OSALG_1:17;
    reconsider sqa = the Sorts of qa as OrderSortedSet of S;
    let s1,s2 being Element of S such that
A17: s1 <= s2;
    let a1 be set such that
A18: a1 in dom (qh.s1);
    a1 in (OSClass R).s1 by A18;
    then a1 in OSClass (R,s1) by Def11;
    then consider x being set such that
A19: x in S1.s1 and
A20: a1 = Class( CompClass(R,CComp(s1)), x) by Def10;
    S1O.s1 c= S1O.s2 by A17,OSALG_1:def 16;
    then reconsider x2 = x as Element of S1.s2 by A19;
A21: a1 = OSClass(R,x2) by A17,A20,Th4;
    reconsider s3 = s1, s4 = s2 as Element of S;
A22: dom (qh.s1) = (the Sorts of qa).s1 & dom (qh.s2) = (the Sorts of qa).
    s2 by FUNCT_2:def 1;
    reconsider x1 = x as Element of S1.s1 by A19;
    x1 in dom (F.s3) by A19,FUNCT_2:def 1;
    then
A23: (F.s3).x1 = (F.s4).x1 by A2,A17;
    sqa.s1 c= sqa.s2 by A17,OSALG_1:def 16;
    hence a1 in dom (qh.s2) by A18,A22;
    thus (qh.s1).a1 = OSHomQuot(F,R,s1).(OSClass(R,x1)) by A20,Def28
      .= (F.s2).x1 by A1,A2,A3,A23,Def27
      .= OSHomQuot(F,R,s2).(OSClass(R,x2)) by A1,A2,A3,Def27
      .= (qh.s2).a1 by A21,Def28;
  end;
end;
