reserve x,y,z for Variable,
  H for ZF-formula,
  E for non empty set,
  a,b,c,X,Y,Z for set,
  u,v,w for Element of E,
  f,g,h,i,j for Function of VAR,E;

theorem Th4:
  E is epsilon-transitive implies (E |= the_axiom_of_unions iff for
  u holds union u in E)
proof
  assume
A1: X in E implies X c= E;
  thus E |= the_axiom_of_unions implies for u holds union u in E
  proof
    set f0 = the Function of VAR,E;
    assume
A2: E |= the_axiom_of_unions;
    let u;
    set f = f0+*(x0,u);
    E |= Ex(x1,All(x2,x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) ))
    by A2,ZF_MODEL:23;
    then
    E,f |= Ex(x1,All(x2,x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0 ) )
    );
    then consider g such that
A3: for x st g.x <> f.x holds x1 = x and
A4: E,g |= All(x2,x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) ) by
ZF_MODEL:20;
A5: f.x0= u by FUNCT_7:128;
    for a be object holds a in g.x1 iff ex X st a in X & X in u
    proof
      let a be object;
A6:   g.x0 = f.x0 by A3;
      thus a in g.x1 implies ex X st a in X & X in u
      proof
        assume
A7:     a in g.x1;
        g.x1 c= E by A1;
        then reconsider a9 = a as Element of E by A7;
        set h = g+*(x2,a9);
A8:     h.x2= a9 by FUNCT_7:128;
        for x st h.x <> g.x holds x2 = x by FUNCT_7:32;
        then
A9:     E,h |= x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) by A4,
ZF_MODEL:16;
        h.x1 = g.x1 by FUNCT_7:32;
        then E,h |= x2 'in' x1 by A7,A8,ZF_MODEL:13;
        then E,h |= Ex(x3,x2 'in' x3 '&' x3 'in' x0) by A9,ZF_MODEL:19;
        then consider m being Function of VAR,E such that
A10:    for x st m.x <> h.x holds x3 = x and
A11:    E,m |= x2 'in' x3 '&' x3 'in' x0 by ZF_MODEL:20;
A12:    m.x0 = h.x0 & m.x2 = h.x2 by A10;
        reconsider X = m.x3 as set;
        take X;
A13:    h.x0 = g.x0 & g.x0 = f.x0 by A3,FUNCT_7:32;
        E,m |= x2 'in' x3 & E,m |= x3 'in' x0 by A11,ZF_MODEL:15;
        hence thesis by A5,A8,A13,A12,ZF_MODEL:13;
      end;
      given X such that
A14:  a in X and
A15:  X in u;
      u c= E by A1;
      then reconsider X as Element of E by A15;
      X c= E by A1;
      then reconsider a9 = a as Element of E by A14;
      set h = g+*(x2,a9);
      set m = h+*(x3,X);
A16:  m.x3= X by FUNCT_7:128;
      m.x0 = h.x0 & h.x0 = g.x0 by FUNCT_7:32;
      then
A17:  E,m |= x3 'in' x0 by A5,A15,A16,A6,ZF_MODEL:13;
A18:  h.x2= a9 by FUNCT_7:128;
      for x st h.x <> g.x holds x2 = x by FUNCT_7:32;
      then
A19:  E,h |= x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) by A4,ZF_MODEL:16;
      m.x2 = h.x2 by FUNCT_7:32;
      then E,m |= x2 'in' x3 by A14,A18,A16,ZF_MODEL:13;
      then ( for x st m.x <> h.x holds x3 = x)& E,m |= x2 'in' x3 '&' x3 'in'
      x0 by A17,FUNCT_7:32,ZF_MODEL:15;
      then E,h |= Ex(x3,x2 'in' x3 '&' x3 'in' x0) by ZF_MODEL:20;
      then E,h |= x2 'in' x1 by A19,ZF_MODEL:19;
      then h.x2 in h.x1 by ZF_MODEL:13;
      hence thesis by A18,FUNCT_7:32;
    end;
    then g.x1 = union u by TARSKI:def 4;
    hence thesis;
  end;
  assume
A20: for u holds union u in E;
  now
    let f;
    reconsider v = union(f.x0) as Element of E by A20;
    set g = f+*(x1,v);
A21: g.x1= v by FUNCT_7:128;
    now
      let h;
      assume
A22:  for x st h.x <> g.x holds x2 = x;
      then
A23:  h.x1 = g.x1;
      E,h |= x2 'in' x1 iff E,h |= Ex(x3,x2 'in' x3 '&' x3 'in' x0)
      proof
        thus E,h |= x2 'in' x1 implies E,h |= Ex(x3,x2 'in' x3 '&' x3 'in' x0)
        proof
          assume E,h |= x2 'in' x1;
          then h.x2 in h.x1 by ZF_MODEL:13;
          then consider X such that
A24:      h.x2 in X and
A25:      X in f.x0 by A21,A23,TARSKI:def 4;
          f.x0 c= E by A1;
          then reconsider X as Element of E by A25;
          set m = h+*(x3,X);
A26:      m.x3= X by FUNCT_7:128;
A27:      g.x0 = f.x0 by FUNCT_7:32;
          m.x2 = h.x2 by FUNCT_7:32;
          then
A28:      E,m |= x2 'in' x3 by A24,A26,ZF_MODEL:13;
          m.x0 = h.x0 & h.x0 = g.x0 by A22,FUNCT_7:32;
          then E,m |= x3 'in' x0 by A25,A26,A27,ZF_MODEL:13;
          then ( for x st m.x <> h.x holds x3 = x)& E,m |= x2 'in' x3 '&' x3
          'in' x0 by A28,FUNCT_7:32,ZF_MODEL:15;
          hence thesis by ZF_MODEL:20;
        end;
        assume E,h |= Ex(x3,x2 'in' x3 '&' x3 'in' x0);
        then consider m being Function of VAR,E such that
A29:    for x st m.x <> h.x holds x3 = x and
A30:    E,m |= x2 'in' x3 '&' x3 'in' x0 by ZF_MODEL:20;
        E,m |= x3 'in' x0 by A30,ZF_MODEL:15;
        then
A31:    m.x3 in m.x0 by ZF_MODEL:13;
        E,m |= x2 'in' x3 by A30,ZF_MODEL:15;
        then m.x2 in m.x3 by ZF_MODEL:13;
        then
A32:    m.x2 in union(m.x0) by A31,TARSKI:def 4;
A33:    h.x1 = g.x1 by A22;
A34:    h.x0 = g.x0 & g.x0 = f.x0 by A22,FUNCT_7:32;
        m.x2 = h.x2 & m.x0 = h.x0 by A29;
        hence thesis by A21,A32,A34,A33,ZF_MODEL:13;
      end;
      hence E,h |= x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) by
ZF_MODEL:19;
    end;
    then
    ( for x st g.x <> f.x holds x1 = x)& E,g |= All(x2,x2 'in' x1 <=> Ex(
    x3,x2 'in' x3 '&' x3 'in' x0) ) by FUNCT_7:32,ZF_MODEL:16;
    hence
    E,f |= Ex(x1,All(x2,x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) )
    ) by ZF_MODEL:20;
  end;
  then
  E |= Ex(x1,All(x2,x2 'in' x1 <=> Ex(x3,x2 'in' x3 '&' x3 'in' x0) ));
  hence thesis by ZF_MODEL:23;
end;
