reserve V for non empty set,
  A,B,A9,B9 for Element of V;
reserve f,f9 for Element of Funcs(V);
reserve m,m1,m2,m3,m9 for Element of Maps V;
reserve a,b for Object of Ens(V);
reserve f,g,f1,f2 for Morphism of Ens(V);

theorem Th36:
 for a,b being Object of Ens(V), f being Morphism of a,b
   st Hom(a,b) <> {}
  holds f is epi & (ex A st ex x1,x2 being set st x1 in A & x2 in A & x1
  <> x2) implies @f is surjective
proof
 let a,b be Object of Ens(V), f be Morphism of a,b such that
A1: Hom(a,b) <> {};
  assume
A2: f is epi;
  given B being Element of V, x1,x2 being set such that
A3: x1 in B and
A4: x2 in B and
A5: x1 <> x2;
A6: cod(@f) c= rng (@f)`2
  proof
    set A = cod(@f);
    reconsider g1 = A --> x1 as Function of A,B by A3,FUNCOP_1:45;
    let x be object;
    assume that
A7: x in A and
A8: not x in rng (@f)`2;
    set h = {x} --> x2, g2 = g1 +* h;
A9: dom h = {x} by FUNCOP_1:13;
A10: rng h = {x2} by FUNCOP_1:8;
    rng g1 = {x1} by A7,FUNCOP_1:8;
    then rng g2 c= {x1} \/ {x2} by A10,FUNCT_4:17;
    then
A11: rng g2 c= {x1,x2} by ENUMSET1:1;
    {x1,x2} c= B by A3,A4,ZFMISC_1:32;
    then
A12: rng g2 c= B by A11;
    dom g1 = A by FUNCOP_1:13;
    then dom g2 = A \/ {x} by A9,FUNCT_4:def 1
      .= A by A7,ZFMISC_1:40;
    then reconsider g2 as Function of A,B by A3,A12,FUNCT_2:def 1,RELSET_1:4;
A13: cod f = A by Def10;
A14: x in {x} by TARSKI:def 1;
    then h.x = x2 by FUNCOP_1:7;
    then
A15: g2.x = x2 by A14,A9,FUNCT_4:13;
A16: g1.x = x1 by A7,FUNCOP_1:7;
    reconsider m1 = [[A,B],g1], m2 = [[A,B],g2] as Element of Maps(V) by A3,Th5
;
    set f1 = @m1, f2 = @m2;
    set h1 = (@f1)`2*(@f)`2, h2 = (@f2)`2*(@f)`2;
    set f1f = (@f1)*(@f), f2f = (@f2)*(@f);
A17: dom m1 = A;
    then
A18: (f1f)`2 = h1 & dom(f1f) = dom(@f) by Th12;
A19: dom m2 = A;
    then
A20: (f2f)`2 = h2 & dom(f2f) = dom(@f) by Th12;
    cod(@f2) = B;
    then
A21: cod f2 = B by Def10;
    dom(@f2) = A;
    then
A22: dom f2 = A by Def9;
    then
A23: f2(*)f = f2f by A13,Th27;
    now
      thus
A24:  dom(h1) = dom(@f) & dom(h2) = dom(@f) by A18,A20,Lm3;
      let z be object;
      set y = (@f)`2.z;
      assume
A25:  z in dom(@f);
      then z in dom (@f)`2 by Lm3;
      then y in rng (@f)`2 by FUNCT_1:def 3;
      then
A26:  not y in {x} by A8,TARSKI:def 1;
      h1.z = g1.y & h2.z = g2.y by A24,A25,FUNCT_1:12;
      hence h1.z = h2.z by A9,A26,FUNCT_4:11;
    end;
    then
A27: h1 = h2;
    cod(f1f) = cod(@f1) by A17,Th12;
    then
A28: f1f=[[dom(@f),cod(@f1)],h1] by A18,Th8;
    cod(f2f) = cod(@f2) by A19,Th12;
    then
A29: f2f=[[dom(@f),cod(@f2)],h2] by A20,Th8;
A30: f1f = f2f by A28,A29,A27;
    cod(@f1) = B;
    then
A31: cod f1 = B by Def10;
    dom(@f1) = A;
    then
A32: dom f1 = A by Def9;
   reconsider B as Object of Ens(V);
A33:  cod f = b by A1,CAT_1:5;
   then
A34:  f1 in Hom(b,B) by A13,A31,A32;
    then reconsider f1 as Morphism of b,B by CAT_1:def 5;
    f2 in Hom(b,B) by A13,A21,A22,A33;
    then reconsider f2 as Morphism of b,B by CAT_1:def 5;
    f1*f = f1(*)f by A1,A34,CAT_1:def 13
     .= f2(*)f by A30,A23,A32,A13,Th27
     .= f2*f by A1,A34,CAT_1:def 13;
    then f1 = f2 by A2,A34;
    hence contradiction by A5,A16,A15,XTUPLE_0:1;
  end;
  rng (@f)`2 c= cod(@f) by Lm3;
  hence rng (@f)`2 = cod(@f) by A6,XBOOLE_0:def 10;
end;
