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 Th15:
  E is epsilon-transitive implies ((for H st { x.0,x.1,x.2 }
misses Free H holds E |= the_axiom_of_substitution_for H) iff for H,f st { x.0,
  x.1,x.2 } misses Free H & E,f |= All(x.3,Ex(x.0,All(x.4,H <=> x.4 '=' x.0)))
  for u holds def_func'(H,f).:u in E )
proof
  assume
A1: X in E implies X c= E;
A2: now
    assume
A3: for H st { x.0,x.1,x.2 } misses Free H holds E |=
    the_axiom_of_substitution_for H;
    let H,f;
    assume that
A4: { x.0,x.1,x.2 } misses Free H and
A5: E,f |= All(x.3,Ex(x.0,All(x.4,H <=> x.4 '=' x.0)));
    E |= the_axiom_of_substitution_for H by A3,A4;
    then E,f |= the_axiom_of_substitution_for H;
    then
A6: E,f |= All(x1,Ex(x2, All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H) )
    )) by A5,ZF_MODEL:18;
    let u;
    set g = f+*(x1,u);
    x0 in { x0,x1,x2 } by ENUMSET1:def 1;
    then
A7: not x0 in Free H by A4,XBOOLE_0:3;
    now
      let a be object;
      assume a in { x1,x2 };
      then a = x1 or a = x2 by TARSKI:def 2;
      then a in { x0,x1,x2 } by ENUMSET1:def 1;
      hence not a in Free H by A4,XBOOLE_0:3;
    end;
    then
A8: { x1,x2 } misses Free H by XBOOLE_0:3;
    for x st g.x <> f.x holds x1 = x by FUNCT_7:32;
    then E,g |= Ex(x2,All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H))) by A6,
ZF_MODEL:16;
    then consider h such that
A9: for x st h.x <> g.x holds x2 = x and
A10: E,h |= All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H)) by ZF_MODEL:20;
    set v = h.x2;
A11: g.x1 = u by FUNCT_7:128;
A12: def_func'(H,f).:u c= v
    proof
      let a be object;
      assume
A13:  a in def_func'(H,f).:u;
      then consider b being object such that
A14:  b in dom def_func'(H,f) and
A15:  b in u and
A16:  def_func'(H,f).b = a by FUNCT_1:def 6;
      reconsider b as Element of E by A14;
      reconsider e = a as Element of E by A13;
      set i = h+*(x4,e);
      set j = i+*(x3,b);
A17:  j.x3 = b by FUNCT_7:128;
A18:  h.x1 = g.x1 by A9;
      j.x1 = i.x1 & i.x1 = h.x1 by FUNCT_7:32;
      then
A19:  E,j |= x3 'in' x1 by A11,A15,A17,A18,ZF_MODEL:13;
      set m1 = f+*(x3,b);
A20:  i.x4 = e by FUNCT_7:128;
      set m = m1+*(x4,e);
A21:  m1.x3 = b by FUNCT_7:128;
      set k = m+*(x1,j.x1);
A22:  m.x4 = e by FUNCT_7:128;
A23:  m.x3 = m1.x3 by FUNCT_7:32;
A24:  now
        let x;
        assume that
A25:    j.x <> k.x and
A26:    x2 <> x;
A27:    x <> x3 by A17,A21,A23,A25,FUNCT_7:32;
        k.x4 = m.x4 by FUNCT_7:32;
        then
A28:    x <> x4 by A20,A22,A25,FUNCT_7:32;
A29:    x <> x1 by A25,FUNCT_7:128;
        then k.x = m.x by FUNCT_7:32
          .= m1.x by A28,FUNCT_7:32
          .= f.x by A27,FUNCT_7:32
          .= g.x by A29,FUNCT_7:32
          .= h.x by A9,A26
          .= i.x by A28,FUNCT_7:32
          .= j.x by A27,FUNCT_7:32;
        hence contradiction by A25;
      end;
A30:  for x st k.x <> m.x holds x1 = x by FUNCT_7:32;
      now
        let y;
        assume
A31:    m.y <> f.y;
        assume that
        x.0 <> y and
A32:    x.3 <> y and
A33:    x.4 <> y;
        m.y = m1.y by A33,FUNCT_7:32;
        hence contradiction by A31,A32,FUNCT_7:32;
      end;
      then E,m |= H iff def_func'(H,f).(m.x.3) = m.x.4 by A5,A7,Def1;
      then E,m |= All(x1,x2,H) by A8,A16,A21,A22,Th11,FUNCT_7:32;
      then E,k |= All(x2,H) by A30,ZF_MODEL:16;
      then E,j |= H by A24,ZF_MODEL:16;
      then
A34:  E,j |= x3 'in' x1 '&' H by A19,ZF_MODEL:15;
      for x st i.x <> h.x holds x4 = x by FUNCT_7:32;
      then
A35:  E,i |= x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H) by A10,ZF_MODEL:16;
A36:  i.x2 = h.x2 by FUNCT_7:32;
      for x st i.x <> j.x holds x3 = x by FUNCT_7:32;
      then E,i |= Ex(x3,x3 'in' x1 '&' H) by A34,ZF_MODEL:20;
      then E,i |= x4 'in' x2 by A35,ZF_MODEL:19;
      hence thesis by A20,A36,ZF_MODEL:13;
    end;
    v c= def_func'(H,f).:u
    proof
      let a be object such that
A37:  a in v;
      v c= E by A1;
      then reconsider e = a as Element of E by A37;
      set i = h+*(x4,e);
A38:  i.x4 = e by FUNCT_7:128;
      for x st i.x <> h.x holds x4 = x by FUNCT_7:32;
      then
A39:  E,i |= x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H) by A10,ZF_MODEL:16;
      i.x2 = h.x2 by FUNCT_7:32;
      then E,i |= x4 'in' x2 by A37,A38,ZF_MODEL:13;
      then E,i |= Ex(x3,x3 'in' x1 '&' H) by A39,ZF_MODEL:19;
      then consider j such that
A40:  for x st j.x <> i.x holds x3 = x and
A41:  E,j |= x3 'in' x1 '&' H by ZF_MODEL:20;
A42:  j.x1 = i.x1 by A40;
      set m1 = f+*(x3,j.x3);
      set m = m1+*(x4,e);
A43:  m.x4 = e by FUNCT_7:128;
      set k = j+*(x1,m.x1);
A44:  m1.x3 = j.x3 by FUNCT_7:128;
A45:  now
        let x;
        assume that
A46:    m.x <> k.x and
A47:    x2 <> x;
        k.x3 = j.x3 by FUNCT_7:32;
        then
A48:    x3 <> x by A44,A46,FUNCT_7:32;
        k.x4 = j.x4 by FUNCT_7:32;
        then
A49:    x4 <> x by A38,A40,A43,A46;
A50:    x1 <> x by A46,FUNCT_7:128;
        then k.x = j.x by FUNCT_7:32
          .= i.x by A40,A48
          .= h.x by A49,FUNCT_7:32
          .= g.x by A9,A47
          .= f.x by A50,FUNCT_7:32
          .= m1.x by A48,FUNCT_7:32
          .= m.x by A49,FUNCT_7:32;
        hence contradiction by A46;
      end;
      now
        let y;
        assume
A51:    m.y <> f.y;
        assume that
        x.0 <> y and
A52:    x.3 <> y and
A53:    x.4 <> y;
        m.y = m1.y by A53,FUNCT_7:32;
        hence contradiction by A51,A52,FUNCT_7:32;
      end;
      then
A54:  E,m |= H iff def_func'(H,f).(m.x.3) = m.x.4 by A5,A7,Def1;
      E,j |= x3 'in' x1 by A41,ZF_MODEL:15;
      then
A55:  j.x3 in j.x1 by ZF_MODEL:13;
      E,j |= H by A41,ZF_MODEL:15;
      then
A56:  E,j |= All(x1,x2,H) by A8,Th11;
A57:  i.x1 = h.x1 & h.x1 = g.x1 by A9,FUNCT_7:32;
A58:  dom def_func'(H,f) = E by FUNCT_2:def 1;
      for x st k.x <> j.x holds x1 = x by FUNCT_7:32;
      then E,k |= All(x2,H) by A56,ZF_MODEL:16;
      then def_func'(H,f).(j.x3) = a by A44,A43,A54,A45,FUNCT_7:32,ZF_MODEL:16;
      hence thesis by A11,A55,A42,A57,A58,FUNCT_1:def 6;
    end;
    then def_func'(H,f).:u = v by A12;
    hence def_func'(H,f).:u in E;
  end;
  now
    assume
A59: for H,f st { x.0,x.1,x.2 } misses Free H & E,f |= All(x.3,Ex(x.0
    ,All(x.4,H <=> x.4 '=' x.0))) for u holds def_func'(H,f).:u in E;
    let H;
    assume
A60: { x.0,x.1,x.2 } misses Free H;
    now
      let a be object;
      assume a in { x1,x2 };
      then a = x1 or a = x2 by TARSKI:def 2;
      then a in { x0,x1,x2 } by ENUMSET1:def 1;
      hence not a in Free H by A60,XBOOLE_0:3;
    end;
    then
A61: { x1,x2 } misses Free H by XBOOLE_0:3;
    x0 in { x0,x1,x2 } by ENUMSET1:def 1;
    then
A62: not x0 in Free H by A60,XBOOLE_0:3;
    thus E |= the_axiom_of_substitution_for H
    proof
      let f;
      now
        assume
A63:    E,f |= All(x3,Ex(x0,All(x4,H <=> x4 '=' x0)));
        now
          let g such that
A64:      for x st g.x <> f.x holds x1 = x;
          reconsider v = def_func'(H,f).: (g.x1) as Element of E by A59,A60,A63
;
          set h = g+*(x2,v);
A65:      h.x2 = v by FUNCT_7:128;
          now
            let i such that
A66:        for x st i.x <> h.x holds x4 = x;
A67:        now
              assume E,i |= x4 'in' x2;
              then
A68:          i.x4 in i.x2 by ZF_MODEL:13;
              i.x2 = h.x2 by A66;
              then consider a being object such that
A69:          a in dom def_func'(H,f) and
A70:          a in g.x1 and
A71:          i.x4 = def_func'(H,f).a by A65,A68,FUNCT_1:def 6;
              reconsider a as Element of E by A69;
              set j = i+*(x3,a);
A72:          j.x3 = a by FUNCT_7:128;
              set m1 = f+*(x3,j.x3);
              set m = m1+*(x4,i.x4);
A73:          m.x4 = i.x4 by FUNCT_7:128;
              set k = m+*(x1,j.x1);
A74:          m1.x3 = j.x3 by FUNCT_7:128;
A75:          now
                let x such that
A76:            j.x <> k.x and
A77:            x2 <> x;
A78:            x1 <> x by A76,FUNCT_7:128;
                j.x4 = i.x4 by FUNCT_7:32;
                then
A79:            x4 <> x by A73,A76,FUNCT_7:32;
                k.x3 = m.x3 by FUNCT_7:32;
                then
A80:            x3 <> x by A74,A76,FUNCT_7:32;
                then j.x = i.x by FUNCT_7:32
                  .= h.x by A66,A79
                  .= g.x by A77,FUNCT_7:32
                  .= f.x by A64,A78
                  .= m1.x by A80,FUNCT_7:32
                  .= m.x by A79,FUNCT_7:32
                  .= k.x by A78,FUNCT_7:32;
                hence contradiction by A76;
              end;
A81:          for x st k.x <> m.x holds x1 = x by FUNCT_7:32;
              now
                let x such that
A82:            m.x <> f.x and
                x.0 <> x and
A83:            x.3 <> x and
A84:            x.4 <> x;
                m.x = m1.x by A84,FUNCT_7:32;
                hence contradiction by A82,A83,FUNCT_7:32;
              end;
              then E,m |= H iff def_func'(H,f).(m.x.3) = m.x.4 by A62,A63,Def1;
              then E,m |= All(x1,x2,H) by A61,A71,A72,A74,A73,Th11,FUNCT_7:32;
              then E,k |= All(x2,H) by A81,ZF_MODEL:16;
              then
A85:          E,j |= H by A75,ZF_MODEL:16;
A86:          h.x1 = g.x1 by FUNCT_7:32;
              j.x1 = i.x1 & i.x1 = h.x1 by A66,FUNCT_7:32;
              then E,j |= x3 'in' x1 by A70,A72,A86,ZF_MODEL:13;
              then
A87:          E,j |= x3 'in' x1 '&' H by A85,ZF_MODEL:15;
              for x st j.x <> i.x holds x3 = x by FUNCT_7:32;
              hence E,i |= Ex(x3,x3 'in' x1 '&' H) by A87,ZF_MODEL:20;
            end;
            now
              assume E,i |= Ex(x3,x3 'in' x1 '&' H);
              then consider j such that
A88:          for x st j.x <> i.x holds x3 = x and
A89:          E,j |= x3 'in' x1 '&' H by ZF_MODEL:20;
              set m1 = f+*(x3,j.x3);
              set m = m1+*(x4,i.x4);
A90:          m.x4 = i.x4 by FUNCT_7:128;
              set k = j+*(x1,m.x1);
A91:          m1.x3 = j.x3 by FUNCT_7:128;
A92:          now
                let x such that
A93:            m.x <> k.x and
A94:            x2 <> x;
A95:            x1 <> x by A93,FUNCT_7:128;
                m.x3 = m1.x3 by FUNCT_7:32;
                then
A96:            x3 <> x by A91,A93,FUNCT_7:32;
                k.x4 = j.x4 by FUNCT_7:32;
                then
A97:            x4 <> x by A88,A90,A93;
                then m.x = m1.x by FUNCT_7:32
                  .= f.x by A96,FUNCT_7:32
                  .= g.x by A64,A95
                  .= h.x by A94,FUNCT_7:32
                  .= i.x by A66,A97
                  .= j.x by A88,A96
                  .= k.x by A95,FUNCT_7:32;
                hence contradiction by A93;
              end;
A98:          i.x2 = h.x2 by A66;
A99:          h.x1 = g.x1 & dom def_func'(H,f) = E by FUNCT_2:def 1,FUNCT_7:32;
              E,j |= x3 'in' x1 by A89,ZF_MODEL:15;
              then
A100:         j.x3 in j.x1 by ZF_MODEL:13;
A101:         now
                let x such that
A102:           m.x <> f.x and
                x.0 <> x and
A103:           x.3 <> x and
A104:           x.4 <> x;
                f.x = m1.x by A103,FUNCT_7:32
                  .= m.x by A104,FUNCT_7:32;
                hence contradiction by A102;
              end;
              E,j |= H by A89,ZF_MODEL:15;
              then
A105:         E,j |= All(x1,x2,H) by A61,Th11;
A106:         m.x3 = m1.x3 & i.x1 = h.x1 by A66,FUNCT_7:32;
              for x st k.x <> j.x holds x1 = x by FUNCT_7:32;
              then E,k |= All(x2,H) by A105,ZF_MODEL:16;
              then E,m |= H by A92,ZF_MODEL:16;
              then
A107:         def_func'(H,f).(m.x.3) = m.x.4 by A62,A63,A101,Def1;
              j.x1 = i.x1 by A88;
              then i.x4 in def_func'(H,f).:(g.x1) by A91,A90,A107,A100,A106,A99
,FUNCT_1:def 6;
              hence E,i |= x4 'in' x2 by A65,A98,ZF_MODEL:13;
            end;
            hence E,i |= x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H) by A67,
ZF_MODEL:19;
          end;
          then
A108:     E,h |= All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H)) by ZF_MODEL:16;
          for x st h.x <> g.x holds x2 = x by FUNCT_7:32;
          hence
          E,g |= Ex(x2,All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H))) by A108,
ZF_MODEL:20;
        end;
        hence
        E,f |= All(x1,Ex(x2,All(x4,x4 'in' x2 <=> Ex(x3,x3 'in' x1 '&' H)
        ))) by ZF_MODEL:16;
      end;
      hence thesis by ZF_MODEL:18;
    end;
  end;
  hence thesis by A2;
end;
