reserve S for non void non empty ManySortedSign,
  U1, U2, U3 for non-empty MSAlgebra over S,
  I for set,
  A for ManySortedSet of I,
  B, C for non-empty ManySortedSet of I;

theorem Th12:
  for F be ManySortedFunction of A, B holds F is "onto" iff for C
  for G, H be ManySortedFunction of B, C st G**F = H**F holds G = H
proof
  let F be ManySortedFunction of A, B;
  thus F is "onto" implies for C for G, H be ManySortedFunction of B, C st G**
  F = H**F holds G = H
  proof
    assume
A1: F is "onto";
    let C;
    let G, H be ManySortedFunction of B, C such that
A2: G**F = H**F;
    now
      let i be object;
      assume
A3:   i in I;
      then reconsider f = F.i as Function of A.i, B.i by PBOOLE:def 15;
      reconsider h = H.i as Function of B.i, C.i by A3,PBOOLE:def 15;
      reconsider g = G.i as Function of B.i, C.i by A3,PBOOLE:def 15;
A4:   rng f = B.i by A1,A3;
      g*f = (H**F).i by A2,A3,MSUALG_3:2
        .= h*f by A3,MSUALG_3:2;
      hence G.i = H.i by A3,A4,FUNCT_2:16;
    end;
    hence thesis;
  end;
  assume that
A5: for C for G, H be ManySortedFunction of B, C st G**F = H**F holds G = H and
A6: not F is "onto";
  consider j be set such that
A7: j in I and
A8: rng (F.j) <> B.j by A6;
  reconsider I as non empty set by A7;
  reconsider j as Element of I by A7;
  reconsider A,B as ManySortedSet of I;
  reconsider F as ManySortedFunction of A,B;
  reconsider f =F.j as Function of A.j,B.j;
  consider Z be set such that
A9: Z <> {} and
A10: ex g, h be Function of B.j, Z st g*f = h*f & g <> h by A8,FUNCT_2:16;
  consider g, h be Function of B.j, Z such that
A11: g*(F.j) = h*(F.j) and
A12: g <> h by A10;
  ex C be ManySortedSet of I st C is non-empty & ex G, H be
  ManySortedFunction of B, C st G**F = H**F & G <> H
  proof
    deffunc F(object) = IFEQ($1, j, Z, B.$1);
    consider C be ManySortedSet of I such that
A13: for i be object st i in I holds C.i = F(i) from PBOOLE:sch 4;
    take C;
    thus C is non-empty
    proof
      let i be object such that
A14:  i in I;
      now
        per cases;
        case
          i = j;
          then IFEQ(i, j, Z, B.i) = Z by FUNCOP_1:def 8;
          hence thesis by A9,A13,A14;
        end;
        case
          i <> j;
          then IFEQ(i, j, Z, B.i) = B.i by FUNCOP_1:def 8;
          hence thesis by A13,A14;
        end;
      end;
      hence thesis;
    end;
    deffunc F(object) = IFEQ($1, j, g, (id B).$1);
    consider G be ManySortedSet of I such that
A15: for i be object st i in I holds G.i = F(i) from PBOOLE:sch 4;
    deffunc F(object) = IFEQ($1, j, h, (id B).$1);
    consider H be ManySortedSet of I such that
A16: for i be object st i in I holds H.i = F(i) from PBOOLE:sch 4;
    now
      let G be ManySortedSet of I;
      let g, h be Function of B.j, Z such that
      g*(F.j) = h*(F.j) and
      g <> h and
A17:  for i be object st i in I holds G.i = IFEQ(i, j, g, (id B).i);
      thus G is Function-yielding
      proof
        let i be object;
        assume i in dom G;
        then
A18:    i in I;
        now
          per cases;
          case
            i = j;
            then IFEQ(i, j, g, (id B).i) = g by FUNCOP_1:def 8;
            hence thesis by A17,A18;
          end;
          case
            i <> j;
            then IFEQ(i, j, g, (id B).i) = (id B).i by FUNCOP_1:def 8;
            hence thesis by A17,A18;
          end;
        end;
        hence thesis;
      end;
    end;
    then reconsider G, H as ManySortedFunction of I by A11,A12,A15,A16;
    now
      let G be ManySortedFunction of I;
      let g, h be Function of B.j, Z such that
      g*(F.j) = h*(F.j) and
      g <> h and
A19:  for i be object st i in I holds G.i = IFEQ(i, j, g, (id B).i);
      thus G is ManySortedFunction of B, C
      proof
        let i be object such that
A20:    i in I;
        now
          per cases;
          case
A21:        i = j;
            then
A22:        IFEQ(i, j, Z, B.i) = Z by FUNCOP_1:def 8;
            IFEQ(i, j, g, (id B).i) = g & C.i = IFEQ(i, j, Z, B.i) by A13,A21,
FUNCOP_1:def 8;
            hence thesis by A19,A21,A22;
          end;
          case
A23:        i <> j;
            then IFEQ(i, j, Z, B.i) = B.i by FUNCOP_1:def 8;
            then
A24:        B.i = C.i by A13,A20;
            IFEQ(i, j, g, (id B).i) = (id B).i by A23,FUNCOP_1:def 8;
            then G.i = (id B).i by A19,A20;
            hence thesis by A20,A24,PBOOLE:def 15;
          end;
        end;
        hence thesis;
      end;
    end;
    then reconsider G, H as ManySortedFunction of B, C by A11,A12,A15,A16;
A25: now
      let i be object such that
A26:  i in I;
      now
        per cases;
        case
A27:      i = j;
          then IFEQ(i, j, h, (id B).i) = h by FUNCOP_1:def 8;
          then
A28:      h = H.i by A16,A26;
          IFEQ(i, j, g, (id B).i) = g by A27,FUNCOP_1:def 8;
          then g = G.i by A15,A26;
          hence (G**F).i = h*(F.j) by A11,A27,MSUALG_3:2
            .= (H**F).i by A27,A28,MSUALG_3:2;
        end;
        case
A29:      i <> j;
          reconsider g9 = G.i as Function of B.i, C.i by A26,PBOOLE:def 15;
          reconsider f9 = F.i as Function of A.i, B.i by A26,PBOOLE:def 15;
          reconsider h9 = H.i as Function of B.i, C.i by A26,PBOOLE:def 15;
A30:      IFEQ(i, j, h, (id B).i) = (id B).i by A29,FUNCOP_1:def 8;
          IFEQ(i, j, g, (id B).i) = (id B).i by A29,FUNCOP_1:def 8;
          then g9 = (id B).i by A15,A26
            .= h9 by A16,A26,A30;
          hence (G**F).i = h9*f9 by A26,MSUALG_3:2
            .= (H**F).i by A26,MSUALG_3:2;
        end;
      end;
      hence (G**F).i = (H**F).i;
    end;
    take G, H;
    G**F is ManySortedSet of I & H**F is ManySortedSet of I by Lm1;
    hence G**F = H**F by A25,PBOOLE:3;
    ex i be set st i in I & G.i <> H.i
    proof
      take i = j;
      thus i in I;
A31:  h = IFEQ(i, j, h, (id B).i) by FUNCOP_1:def 8
        .= H.i by A16;
      g = IFEQ(i, j, g, (id B).i) by FUNCOP_1:def 8
        .= G.i by A15;
      hence thesis by A12,A31;
    end;
    hence thesis;
  end;
  hence contradiction by A5;
end;
