reserve X,x for set;

theorem Th1:
  for Z being set, M being ManySortedSet of Z st for x being set st
  x in Z holds M.x is ManySortedSet of x for f being Function st f = Union M
  holds dom f = union Z
proof
  let Z be set, M be ManySortedSet of Z such that
A1: for x being set st x in Z holds M.x is ManySortedSet of x;
  let f be Function;
  assume f = Union M;
  then
A2: f = union rng M by CARD_3:def 4;
  for x being object holds x in dom f iff ex Y being set st x in Y & Y in Z
  proof
    let x be object;
    thus x in dom f implies ex Y being set st x in Y & Y in Z
    proof
      assume x in dom f;
      then [x,f.x] in f by FUNCT_1:def 2;
      then consider g being set such that
A3:   [x,f.x] in g and
A4:   g in rng M by A2,TARSKI:def 4;
      consider a being object such that
A5:   a in dom M and
A6:   g = M.a by A4,FUNCT_1:def 3;
      reconsider a as set by TARSKI:1;
A7:   a in Z by A5,PARTFUN1:def 2;
      then reconsider g as ManySortedSet of a by A1,A6;
      take dom g;
      thus x in dom g by A3,FUNCT_1:1;
      thus thesis by A7,PARTFUN1:def 2;
    end;
    given Y being set such that
A8: x in Y and
A9: Y in Z;
    reconsider g = M.Y as ManySortedSet of Y by A1,A9;
    Y = dom g by PARTFUN1:def 2;
    then
A10: [x,g.x] in g by A8,FUNCT_1:1;
    Z = dom M by PARTFUN1:def 2;
    then g in rng M by A9,FUNCT_1:def 3;
    then [x,g.x] in f by A2,A10,TARSKI:def 4;
    hence thesis by FUNCT_1:1;
  end;
  hence thesis by TARSKI:def 4;
end;
