
theorem
for X be with_empty_element set, F be FinSequence of X holds
 ex G be Function of NAT,X st
  (for i be Nat holds F.i = G.i) & Union F = Union G
proof
   let X be with_empty_element set;
   let F be FinSequence of X;
   defpred P[Element of NAT,set] means
    ($1 in dom F implies F.$1 = $2) & (not $1 in dom F implies $2 = {});
A1:for i be Element of NAT ex y be Element of X st P[i,y]
   proof
    let i be Element of NAT;
    per cases;
    suppose A2: i in dom F; then
     F.i in rng F & rng F c= X by FUNCT_1:3; then
     reconsider y = F.i as Element of X;
     take y;
     thus P[i,y] by A2;
    end;
    suppose A3: not i in dom F;
     reconsider y = {} as Element of X by SETFAM_1:def 8;
     take y;
     thus P[i,y] by A3;
    end;
   end;
   consider G be Function of NAT,X such that
A4: for i be Element of NAT holds P[i,G.i] from FUNCT_2:sch 3(A1);
   take G;
A5:now let i be Nat;
    per cases;
    suppose i in dom F;
     hence F.i = G.i by A4;
    end;
    suppose not i in dom F;
     reconsider j = i as Element of NAT by ORDINAL1:def 12;
     P[j,G.j] by A4;
     hence F.i = G.i by FUNCT_1:def 2;
    end;
   end;
B1:Union F = union rng F & Union G = union rng G by CARD_3:def 4;
   now let x be object;
    assume x in Union F; then
    consider A be set such that
A7:  x in A & A in rng F by B1,TARSKI:def 4;
    consider k be object such that
A8:  k in dom F & A = F.k by A7,FUNCT_1:def 3;
    reconsider k as Nat by A8;
    dom G = NAT by FUNCT_2:def 1; then
    A = G.k & G.k in rng G by A5,A8,FUNCT_1:3;
    hence x in Union G by A7,B1,TARSKI:def 4;
   end; then
A9:Union F c= Union G by TARSKI:def 3;

   now let x be object;
    assume x in Union G; then
    consider A be set such that
A10: x in A & A in rng G by B1,TARSKI:def 4;
    consider k be object such that
A11: k in dom G & A = G.k by A10,FUNCT_1:def 3;
    reconsider k as Nat by A11;
A12:now assume not k in dom F; then
     F.k = {} by FUNCT_1:def 2;
     hence contradiction by A5,A10,A11;
    end;
A13:F.k = G.k by A5;
    F.k in rng F by A12,FUNCT_1:3;
    hence x in Union F by B1,A10,A11,A13,TARSKI:def 4;
   end; then
   Union G c= Union F by TARSKI:def 3;
   hence thesis by A5,A9,XBOOLE_0:def 10;
end;
